Domanda

So we have an application launcher which can (should) run new apps created in clickOnce and older apps that use a remoting type of logic

When trying to run the apps I received the following message

Cannot load assembly. Error details: System.IO.FileLoadException: Could not load 
file or assembly 'program' or one of its dependencies. Operation is not 
supported.  (Exception from HRESULT: 0x80131515) File name:'program'  
---> System.NotSupportedException: An attempt was made to load an assembly from
a network location which would have caused the assembly to be sandboxed in 
previous versions of the .NET Framework. This release of the .NET Framework does 
not enable CAS policy by default, so this load may be dangerous. If this load is 
not intended to sandbox the assembly, please enable the loadFromRemoteSources 
switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

Googling I found this piece of code which says update the app config

Loading blocked and network-hosted assemblies with .NET 4

That fix the older apps but now broke the newer apps

So then I found Setting useLegacyV2RuntimeActivationPolicy At Runtime

And this "works" in that if I load a new app first, no issue, then I load an older app and it is ok, but then if I go to load a new app it stops working.

So either I need to know how to unbind BindAsLegacyV2Runtime when I am about to run new apps. Or I need a whole other approach?

Thanks

È stato utile?

Soluzione

Adding

<runtime>
     <loadFromRemoteSources enabled="true"/>
</runtime>

Fixed the issue for both types of application

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top