Mixed mode assembly is built against version xxxx

310 views Asked by At

I'm trying to make a movie play in my application:

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     Dim audioFile As Audio = New Audio("My.Resources.MyMovie.mov")
     audioFile.Play()
 End Sub

MyMovie is a .mov file and is saved under My.Resources and I want to access that file in vb.net program. When a button is clicked, I want that movie to play. The problem is, when I clicked the button, I receive this error:

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.

As well as the above error, I also get the following:

FileLoadException was unhandled.

1

There are 1 answers

0
AStopher On

You're attempting to use an older library with a newer version of .NET. In an ideal world, every library would be built & updated for the newest platform, but this isn't the case.

useLegacyV2RuntimeActivationPolicy needs to be set to true in your app.Config file, for example:

<startup useLegacyV2RuntimeActivationPolicy="true">
   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

Obviously if you use a higher version of .NET than 4.0, you need to swap out the version parameters Version=v4.0 and Version="v4.0" to the version you're using.

Additional information on the <startup> element can be found here, from the official documentation I linked:

Specifies whether to enable the .NET Framework 2.0 runtime activation policy or to use the .NET Framework 4 activation policy.

The FileLoadException was unhandled. error is caused by the above.