StructureToPtr with dot net 4.5.1
GieltjE
Posts: 29 Bronze 2
The following error appears while running a dot net 4.5.1 assembly (the code is contained in a merged dll):
Setting MandatoryPath doesn't help, the following (tabcontrol extend) code is involved:
Setting the dll back to dotnet 4.5.0 is a temporary solution
SmartAssembly.InformationException: SmartAssembly has encountered an invalid symbol:
[mscorlib]System.Runtime.InteropServices.Marshal::StructureToPtr System.Void(!!0, System.IntPtr, System.Boolean)
The most likely cause is that SmartAssembly has used a different version of a dependency from the version used by FYN Retail.exe.
If the details below are wrong, please use the MandatoryPath attribute in the .saproj file to ensure that the correct version of the dependency is found.
Assembly that should contain the missing symbol: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll
SmartAssembly has encountered an error while running your project.
Failed: SmartAssembly.InformationException: SmartAssembly has encountered an invalid symbol:
[mscorlib]System.Runtime.InteropServices.Marshal::StructureToPtr System.Void(!!0, System.IntPtr, System.Boolean)
The most likely cause is that SmartAssembly has used a different version of a dependency from the version used by FYN Retail.exe.
If the details below are wrong, please use the MandatoryPath attribute in the .saproj file to ensure that the correct version of the dependency is found.
Assembly that should contain the missing symbol: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll
Please run SmartAssembly in User-Interface mode for more information.
Setting MandatoryPath doesn't help, the following (tabcontrol extend) code is involved:
protected override void WndProc(ref Message m) { if (m.Msg == 0x1300 + 40) { Rect rc = (Rect)m.GetLParam(typeof(Rect)); rc.Left -= 4; rc.Right += 4; rc.Top -= 1; rc.Bottom += 2; Marshal.StructureToPtr(rc, m.LParam, true); } base.WndProc(ref m); }
Setting the dll back to dotnet 4.5.0 is a temporary solution
Comments
If I set the mandatory path for the dll that get's merged it doesn't recognize the dll anymore so it has to be set on the main assembly.
This is basically an error in how we resolve the assembly- if you point the mandatorypath to:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib
That should now work as its the *real* assembly.
Unfortunately that doesn't make a difference.
Name: System.Runtime.InteropServices.Marshal
If its not there- that at least explains why the error hasn't gone away and we'll have to work out how to point to the right mscorlib. If it is there, we need to work out how to get SA to find it.
Reflector is available as a free trial download from our website.
With the corresponding saproject, I can supply the complete project if requested.
<Assembly AssemblyName="mscorlib, Culture=neutral, PublicKeyToken=b77a5c561934e089">
to:
<Assembly AssemblyName="mscorlib, Culture=neutral, PublicKeyToken=b77a5c561934e089" mandatorypath="C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib ">
Still the same error.
1.MandatoryPath="C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll"
It seems necessary to point to the full physical location of the real mscorlib. This can be found using, for example, Reflector (open it up in, for example, C:\Windows\Microsoft.NET\Framework\v4.0.30319\) and look at the bottom left window- reflector tells you the full physical location)
2. Smartassembly has a tendency to cache the settings file so one workaround I use is to copy the full install path:
C:\Program Files\Red Gate\SmartAssembly 6\*.*
and put it somewhere convenient, such as your desktop, the just run it form this new path- it re-reads all files.
This has been tested extensively. If you still get problems, please let me know which step and send new smartassembly debug log.
This solution works until the application references mscorlib 2 and 4 if you reference an dotnet 2 dll. Unfortunately I can't get a debug for some reason.
In the .saproj:
With the following change I get it to compile:
However, I now get the following warning:
However, so far I have not noticed any problems.