Page 1 of 1

Error: Mixed mode assembly

Posted: Tue Oct 04, 2011 3:02 pm
by drtech
I am having trouble getting past this error building 11.1

I read the info at http://www.opendental.com/manual/sourcecode.html

it says
Error: Mixed mode assembly etc. We have already altered the app.config file for the Open Dental project to handle one of these errors. If you look closely at the remaining error, the filename is SGEN, which is an MS exe that generates a serialization assembly. The quick fix for this error is to right click the OD project, properties, build tab, and at the bottom, change 'generate serialization assembly' to off. This will, however, result in Open Dental running a little slower. A better fix is to find the sgen.exe, for example at "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\sgen.exe. Once you find it, create (or possibly alter) an sgen.exe.config to look like this:
<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
</startup>
</configuration>
I found my sgen.exe.config file in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin since it is 64bit. The file was write protected, so I unprotected it, changed the file to the above specifications and tried to build again.

There was no change and I still got the same error: (need to write protect it again? I will try that...)

Error 33 Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. C:\svn\beta\OpenDental\SGEN OpenDental

I am also getting 2 other errors that I have never seen before:
Error 35 Application Configuration file "app.config" is invalid. Could not find file 'C:\svn\beta\ServiceManager\app.config'. C:\svn\beta\ServiceManager\app.config ServiceManager
Is this a missing file from the SVN?

Error 31 Metadata file 'C:\svn\beta\OpenDental\bin\Release\OpenDental.exe' could not be found TestCanada
Is this just because of the other errors and the file is not yet built i suppose?


Using Visual Studio 2010 Pro

Re: Error: Mixed mode assembly

Posted: Tue Oct 04, 2011 3:17 pm
by drtech
I restarted Visual Studio. Then I write protected the edited file again, and then cleaned the project from within visual studio. When I built again, the SGEN error was resolved!

I still have


Error 33 Application Configuration file "app.config" is invalid. Could not find file 'C:\svn\beta\ServiceManager\app.config'. C:\svn\beta\ServiceManager\app.config ServiceManager


Is this a file that needs to be added to the SVN or is there some other config I am missing?

Re: Error: Mixed mode assembly

Posted: Tue Oct 04, 2011 3:22 pm
by drtech
Actually, I had turned off the serialization assembly also. When I turned it back on (I think you have to reload the project for this to take effect? I still get the SGEN error.

Re: Error: Mixed mode assembly

Posted: Tue Oct 04, 2011 7:10 pm
by jordansparks
Yes, it's just a missing file that you don't really need anyway. Just exclude that project from your build.

Re: Error: Mixed mode assembly

Posted: Wed Oct 05, 2011 1:41 am
by drtech
ok, i will exclude that project, but I still can't get it to build with serialization assembly turned on. Any ideas on why the directions on the source code page are not working for me? I don't want it to run slower by leaving serialization off...

Re: Error: Mixed mode assembly

Posted: Wed Oct 05, 2011 2:35 am
by drtech
i figured it out.

There are mutiple sgen.exe files. I was configuring the first one I found. The one you have to configure is "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools." I was trying to edit it in "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin" as you can see above.

the important thing here is "NETFX 4.0 Tools"

There are also sgen.exe/sgen.exe.config files one directory up, and in x64 folders (which I assume are for 64bit builds, which we don't do)

MAKE SURE YOU ARE CONFIGURING THE RIGHT ONE. Then you can build in serialization.

Re: Error: Mixed mode assembly

Posted: Thu Jul 05, 2012 9:42 am
by beattyph
I received the following SGEN related error:

Error 39 Could not load file or assembly 'file:///Z:\DataHD\tappuniDental\opendental12.2\Required dlls\CDT.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) Z:\DataHD\tappuniDental\opendental12.2\OpenDentBusiness\SGEN OpenDentBusiness

I traced this back to the fact that I am accessing the source code from a shared folder & found a solution here:

http://stackoverflow.com/questions/3007 ... om-hresult

The sgen.exe.config file can be modified to solve this issue. My sgen.exe.config file looks like

Code: Select all

<?xml version ="1.0"?>
<configuration>
 <startup useLegacyV2RuntimeActivationPolicy="true">
 <supportedRuntime version="v4.0.30319"/>
 </startup>
 <runtime>
    <loadFromRemoteSources enabled="true" />
 </runtime>
</configuration>
Maybe this will help someone facing the same issue.

Re: Error: Mixed mode assembly

Posted: Fri Jul 06, 2012 6:20 am
by drtech
I rebuilt my machine...and now I can't get it to work. Works fine in debug mode, but release gives me sgen errors again...

Re: Error: Mixed mode assembly

Posted: Sun Sep 23, 2012 3:23 pm
by drtech
installed .net 4.5

created the file sgen.exe.config in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools with code:

<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
</startup>
</configuration>

Now it works in release mode and debug!

Re: Error: Mixed mode assembly

Posted: Sun Sep 23, 2012 7:14 pm
by wjstarck
That's great.

Thanks for tracking this down David

Re: Error: Mixed mode assembly

Posted: Sat Oct 27, 2012 7:07 pm
by railgrab
Thank you DrTech! I just successfully built v12.3 with my 64 bit Windows 7 machine after installing .net4.5 and adding your sgen.exe.config file. I used Visual Studio Pro 2010.

Re: Error: Mixed mode assembly

Posted: Thu Feb 21, 2013 12:12 pm
by Justin Shafer
Yay! Thanks! Good Job!

Re: Error: Mixed mode assembly

Posted: Thu Feb 21, 2013 1:47 pm
by drtech
Just figured out in Windows 8 the file path changed slightly

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools

Re: Error: Mixed mode assembly

Posted: Sat Apr 27, 2013 9:46 am
by jackcraig66
Thanks to everyone who posted on this subject - very useful info - on my Windows 8 x64 system I had to add (rather than edit) the sgen.exe.config file to C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools - no problem after that :)

Re: Error: Mixed mode assembly

Posted: Fri Aug 30, 2013 3:51 pm
by jsalmon
We just updated to Microsoft Visual Studio Professional 2012 and the Mixed mode assembly error happens every time I run Release with Generate serialization assembly turned on (specifically the Open Dental project). However, it doesn't happen when I use VS2010 Pro most likely due to the workaround / settings mentioned above (or in our online manual).
I'm quite baffled and haven't been able to find an explanation on any Microsoft forums. So be cautious when updating to VS2012. I'll post an answer here when I figure out the solution.

Re: Error: Mixed mode assembly

Posted: Fri Aug 30, 2013 4:27 pm
by jsalmon
So I got it to work but stumbled across it out of a fit of frustration. I decided to see just how many sgen.exe's there were on my computer and create an sgen.exe.config for every single one of them and then after doing that it compiles without an issue. Just to give you guys an idea of what I did:
Created an sgen.exe.config file:

Code: Select all

<?xml version ="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
</configuration>
Then placed the sgen.exe.config file in every single location that I found an sgen.exe: (note the x86 paths that contain x64 folders!!!) :roll: Come on Microsoft...
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\x64
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin

^^I have no idea which one did the trick nor do I care anymore.

Re: Error: Mixed mode assembly

Posted: Tue Sep 03, 2013 2:51 pm
by jordansparks
We will add this to our manual.

Re: Error: Mixed mode assembly

Posted: Thu Nov 07, 2013 11:03 pm
by B.Thomas
Thanks for the sgen.exe.config tip. I was getting frustrated for a while.

Re: Error: Mixed mode assembly

Posted: Sun May 12, 2019 7:15 pm
by drtech
Found the new place to add the sgen.exe.config for windows 10 v1810 and visual studio community ed 2019

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools

Re: Error: Mixed mode assembly

Posted: Wed Oct 30, 2019 11:29 am
by drtech
additional
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX\NETFX 4.8 Tools