问题
I'm Trying to embed Awesomium into my project executable file. In the documentation of Awesomium, they said that set the target platform of your project to X86
. Is that mean there is only Unmanaged32Assemblies
available?
I add this line to FodyWeaver.xml
file:
<Costura Unmanaged32Assemblies='Awesomium.Core|Awesomium.Windows.Forms'/>
But I got an exception that says:
System.TypeInitializationException was unhandled
Message: An unhandled exception of type 'System.TypeInitializationException' occurred in mscorlib.dll
Additional information: The type initializer for '<Module>' threw an exception.
I also try tried this:
<Costura
Unmanaged32Assemblies='Awesomium.Core|Awesomium.Windows.Forms'
Unmanaged64Assemblies='Awesomium.Core|Awesomium.Windows.Forms' />
But exactly same exception was thrown.
Update
Also Tried this:
<Costura
Unmanaged32Assemblies='awesomium'
Unmanaged64Assemblies='awesomium'/>
and this:
<Costura
Unmanaged32Assemblies='awesomium'/>
It's make my exe file about 4 MB bigger, but again same exception was thrown
回答1:
If the assembly you're trying to embed using Unmanaged32Assemblies
is not a mixed-mode assembly, then that method won't work.
Instead, try adding something like this to your .csproj
file:
<ItemGroup>
<EmbeddedResource Include="..\packages\path\to\awesomium.dll">
<LogicalName>costura32.%(Filename)%(Extension)</LogicalName>
<Visible>false</Visible>
</EmbeddedResource>
</ItemGroup>
Costura will find this resource at load time and extract it to a temporary directory so that your app will be able to find/load it.
来源:https://stackoverflow.com/questions/35237624/the-type-initializer-for-module-threw-an-exception-when-try-to-embed-awesomi