Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosting Process "File Lock"'s are causing Dynamic Proxy to fail on win10-x64 #253

Closed
ghost opened this issue Apr 21, 2017 · 5 comments
Closed

Comments

@ghost
Copy link

ghost commented Apr 21, 2017

Dynamic proxy uses static assembly names for generation of proxy types. This is very much needed when it comes to strong naming assemblies and declaring friend assemblies. The trouble is you cannot control what hosting processes(or consumers of Castle DP) do.

A file lock on "CastleDynProxy2.dll" via a test run in Resharper, will cause an I/O collision when running tests via the console.

Is there perhaps a way of creating a "bottom up" way of revealing this?

@jonorossi
Copy link
Member

This is only a problem for unit tests because they persist their dynamic assembly to the test working directory so the peverify tool can be automatically run over the assembly.

Oh, I thought you said you had this problem also when running on the build server which doesn't have VS or ReSharper.

Does this only occur when you are running unit tests at the same time in both ReSharper and CLI? Or is a ReSharper process holding a file lock just sitting there idle?

@ghost
Copy link
Author

ghost commented Apr 22, 2017

This might also be a problem in appveyor.

See here: https://ci.appveyor.com/project/fir3pho3nixx/core/build/4.0.37

Errors, Failures and Warnings

  1. Failed : Castle.DynamicProxy.Tests.ModuleScopeTestCase
    One or more child tests had errors
  2. Error : Castle.DynamicProxy.Tests.ModuleScopeTestCase.SaveWithPath
    System.IO.IOException : The process cannot access the file 'C:\Users\appveyor\AppData\Local\Temp\1\tmp2388.tmp' because it is being used by another process.
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    at System.IO.File.InternalDelete(String path, Boolean checkHost)
    at Castle.DynamicProxy.ModuleScope.SaveAssembly(Boolean strongNamed)
    at Castle.DynamicProxy.Tests.ModuleScopeTestCase.SaveWithPath()

It happens when resharper is sitting there idle. Sometimes ...

@jonorossi
Copy link
Member

The error with ModuleScopeTestCase.SaveWithPath is strange, nothing outside the unit test uses the same temp file name, so either it is blocking itself or there is anti-virus running (which AppVeyor say they don't have).

[Test]
public void SaveWithPath()
{
	var strongModulePath = Path.GetTempFileName();    //<<<<<<<<<<
	var weakModulePath = Path.GetTempFileName();    //<<<<<<<<<<

	File.Delete(strongModulePath);
	File.Delete(weakModulePath);

	Assert.IsFalse(File.Exists(strongModulePath));
	Assert.IsFalse(File.Exists(weakModulePath));

	var scope = new ModuleScope(true,false, "Strong", strongModulePath, "Weak", weakModulePath);
	scope.ObtainDynamicModuleWithStrongName();
	scope.ObtainDynamicModuleWithWeakName();

	scope.SaveAssembly(true);
	scope.SaveAssembly(false);

	Assert.IsTrue(File.Exists(strongModulePath));
	Assert.IsTrue(File.Exists(weakModulePath));

	File.Delete(strongModulePath);
	File.Delete(weakModulePath);
}

@ghost
Copy link
Author

ghost commented Apr 24, 2017

@stakx
Copy link
Member

stakx commented Jan 6, 2021

Closing due to several years of inactivity.

@stakx stakx closed this as completed Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants