Hi,
I tried to compile CellUtility addin example with VS 2010 and also changed target framework to ".NET framework 4". It succeded. When I load the addin in SS2, an unhandled exception (System.BadImageFormatException) occurs.
Is the .NET 4 framework development supported for current version of Microstation?
Regards
Vit
Exception body and call stack:
System.BadImageFormatException: Could not load file or assembly 'cellutility' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.File name: 'cellutility' at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at Bentley.MicroStation.DigitalRights.LoadAssemblyByTextName(String textname, Boolean verbose) at Bentley.Internal.MicroStation.DotNetShim.Launcher.GetAddInTypeThroughReflection(Int32* statusCodeP, String* taskIDOverridePP, String assemblyRootName, String taskId) at Bentley.Internal.MicroStation.DotNetShim.Launcher.LoadMdlProgram(IntPtr statusCodeP, String mdlAppNameParam, String taskID, IntPtr forkFunc, IntPtr forkParams)
Unknown said:Is the .NET 4 framework development supported for current version of Microstation?
Could not load file or assembly 'cellutility' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Did you read that exception?
You can try to use CorBindToRuntimeEx to get .NET 4 Framework available in MicroStation, load there all ustation.dll references and then try to load that addin. But I think that it vould be better to use .NET 3.5 or .NET 2.0. What from .NET 4 you like to use?
Dan
Hi Dan,
thanx for your comments. I've found another way how to make .NET 4 addin running - modification of the ustation.exe configuration file (MSDN: Startup Settings Schema).
We were facing high memory load and LOH fragmentation issues on some projects. That was the main reason why we moved to the .NET 4 framework. (See comments at following discussion: Large object heap fragmentation)
Could you (or someone else) elaborate on your process to make the .Net 4 addin running? I tried editing the ustation.exe.config file and am loosely familiar with the app.config file options, but failed. Maybe post the edited snipped of what you altered or added?
Thanks in advance
It should be enough to replace:
<startup> <supportedRuntime version="v2.0.50727"/></startup>
by:
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/></startup>
HTH
Beautiful! Thanks, I'd just added another supportedRuntime element but not the LegacyV2 attribute.
I am not sure which is safer, but if you are happy with it... LegacyV2 is more about using older assemblies in v4 applications so probably your choice is better.
Did not LegacyV2 solution work for you?
Sorry...waaay belated response. Yes the LegacyV2 worked