Error: Mixed mode assembly

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Error: Mixed mode assembly

Post by drtech » Tue Oct 04, 2011 3:02 pm

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
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Error: Mixed mode assembly

Post by drtech » Tue Oct 04, 2011 3:17 pm

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?
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Error: Mixed mode assembly

Post by drtech » Tue Oct 04, 2011 3:22 pm

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.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
jordansparks
Site Admin
Posts: 5739
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: Error: Mixed mode assembly

Post by jordansparks » Tue Oct 04, 2011 7:10 pm

Yes, it's just a missing file that you don't really need anyway. Just exclude that project from your build.
Jordan Sparks, DMD
http://www.opendental.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Error: Mixed mode assembly

Post by drtech » Wed Oct 05, 2011 1:41 am

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...
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Error: Mixed mode assembly

Post by drtech » Wed Oct 05, 2011 2:35 am

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.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

beattyph
Posts: 6
Joined: Sun Nov 08, 2009 4:22 pm

Re: Error: Mixed mode assembly

Post by beattyph » Thu Jul 05, 2012 9:42 am

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.

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Error: Mixed mode assembly

Post by drtech » Fri Jul 06, 2012 6:20 am

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...
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Error: Mixed mode assembly

Post by drtech » Sun Sep 23, 2012 3:23 pm

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!
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Error: Mixed mode assembly

Post by wjstarck » Sun Sep 23, 2012 7:14 pm

That's great.

Thanks for tracking this down David
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

railgrab
Posts: 3
Joined: Thu Oct 18, 2007 12:59 pm

Re: Error: Mixed mode assembly

Post by railgrab » Sat Oct 27, 2012 7:07 pm

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.

User avatar
Justin Shafer
Posts: 596
Joined: Sat Jul 28, 2007 7:34 pm
Location: Fort Worth, TX.

Re: Error: Mixed mode assembly

Post by Justin Shafer » Thu Feb 21, 2013 12:12 pm

Yay! Thanks! Good Job!

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Error: Mixed mode assembly

Post by drtech » Thu Feb 21, 2013 1:47 pm

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
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

jackcraig66
Posts: 12
Joined: Tue Apr 09, 2013 12:24 pm

Re: Error: Mixed mode assembly

Post by jackcraig66 » Sat Apr 27, 2013 9:46 am

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 :)

User avatar
jsalmon
Posts: 1551
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Error: Mixed mode assembly

Post by jsalmon » Fri Aug 30, 2013 3:51 pm

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.
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

User avatar
jsalmon
Posts: 1551
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Error: Mixed mode assembly

Post by jsalmon » Fri Aug 30, 2013 4:27 pm

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.
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

User avatar
jordansparks
Site Admin
Posts: 5739
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: Error: Mixed mode assembly

Post by jordansparks » Tue Sep 03, 2013 2:51 pm

We will add this to our manual.
Jordan Sparks, DMD
http://www.opendental.com

User avatar
B.Thomas
Posts: 160
Joined: Mon Jul 23, 2007 11:00 pm

Re: Error: Mixed mode assembly

Post by B.Thomas » Thu Nov 07, 2013 11:03 pm

Thanks for the sgen.exe.config tip. I was getting frustrated for a while.

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Error: Mixed mode assembly

Post by drtech » Sun May 12, 2019 7:15 pm

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
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Error: Mixed mode assembly

Post by drtech » Wed Oct 30, 2019 11:29 am

additional
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX\NETFX 4.8 Tools
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

Post Reply