Reputation: 2791
I'm hoping someone out there can explain this behavior that I'm seeing. There are 3 main parts to my problem:
The Managed C++ assembly defines an interface, let's call it ISetupHelper
. There is a class in the C# assembly that implements this interface (The C# assembly has a reference to the managed C++ assembly). Let's call this class SetupHelper
.
Since the Wise setup can't call directory to the C# assembly, we have this managed C++ assembly in between. There is a method that the setup calls to create an interface of a class that implements ISetupHelper
. I does this by passing 2 strings to the C++ method, the assembly path (to the C# assembly) and the type name.
The C++ method looks like this:
Assembly^ assembly = Assembly::LoadFrom(assemblyName);
Object^ provider = assembly->CreateInstance(typeName);
WiseServices::SetupHelper = safe_cast<ISetupHelper^>(provider);
This has worked very well for us for a number of years. Now we are trying to add support for Windows Server 2012/R2. These versions of Windows come with 4.5 and 4.5.1 installed respectively.
Here is where the odd problem happens. If the setup is run from a path with a long name it does not work if you run it from the short version of the path. When I say it doesn't work, I mean the cast fails. For example:
c:\reallylongname
c:\really~1
I turned on the Fusion logger, and when the cast fails it tries to load the C++ assembly again:
If you do this exact same thing on a Windows Server 2008 R2 machine with only .NET 4.0 installed, running from the short path works just fine (the cast is successful).
It seems as if something in the CLR has changed in the way it loads assemblies and in particular when loading an assembly with the same name as one that has already been loaded.
Upvotes: 1
Views: 728