c# - Visual Studio Unit Test locking dll -



c# - Visual Studio Unit Test locking dll -

simple unit test abstract class p/invoked methods leaving unmanaged dll locked when tests executed. oddly plenty lock not happen when debugging test, when test run.

similar problem here reported on visual studio 2012 , using similar workaround, bit less hacky nonetheless not solution.

workaround

added "teardown" method executed 1 time tests terminate manually free unmanaged library.

[dllimport("kernel32", setlasterror=true)] static extern bool freelibrary(intptr hmodule); [assemblycleanup] public static void teardown() { foreach (processmodule mod in process.getcurrentprocess().modules) { if (mod.modulename == "example.dll") { freelibrary(mod.baseaddress); } } }

my solution running unit tests in vs:

run instance of console administrator , come in script:

taskkill /f /im vstest* /t

before running test switch console , execute line above kill process related test framework.

i manually build test project before running test because if forget kill processes, vs stuck in build mode forever.

unfortunately not solve main issue need kill vs every 20 minutes while testing or debugging because gets slow point of beingness unusable. ):

for fairness must add together run tests resharper test session.

c# unit-testing visual-studio-2013 pinvoke

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -