.NET 4.0 Issues

Using (or providing) Microsoft.NET Classes

.NET 4.0 Issues

Postby paulmansour on Thu Feb 26, 2015 6:10 pm

I recently changed my environment and started using .net 4.0. Longstanding dlls (like DotNetZip) that I had been using started failing with this error:

      EXCEPTION: Request for the permission of type 'System.Security.Permissions.FileIOPer
mission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
' failed.


The failure occurs on my windows 7 machine. I have a windows surface with Windows 8.1 on it, and it all works great.

These are dlls I just drop in a folder ... no GAC install or anything like that.

Any ideas why?
paulmansour
 
Posts: 418
Joined: Fri Oct 03, 2008 4:14 pm

Re: .NET 4.0 Issues

Postby PGilbert on Tue Mar 03, 2015 7:02 pm

To my surprise I am able to reproduce this behavior also. With a 3rd party dll in a random folder it will work with Windows 8 and it will not work with Window 7. It will work however with Windows 7 if the 3rd party dll is in the same directory as dyalog.exe.

Some solution on the web but are related to a web server. The basic of the problem is that there is not enough 'Trust' for the dll from Windows to execute it. Looks like it can be modify in the file dyalog.config.exe file but don't know how.

Any idea Brian ?
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: .NET 4.0 Issues

Postby Vince|Dyalog on Thu Mar 05, 2015 4:53 pm

Hi Paul and Pierre,

Please look to see if the DLLS are "blocked", this usually happens if they've been downloaded. There's an "Unblock" button on the General Tab of the properties dialog for the file.

Or, check if the file is on a mapped network drive--default policy doesn't always allow that.

JD uses the following dyalog.exe.config file:

<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
<runtime>
<!-- <NetFx40_LegacySecurityPolicy enabled="true"/> -->
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>

Does modifying your dyalog.exe.config file to this help?

Security and permissions on Windows are quite strange and mysterious. I had an icon in a folder which could run our WPF samples. If I dragged that same icon to the windows taskbar and pinned it there and started Dyalog there, my Dyalog wouldn't run our WPF samples. I found out that starting the icon there gave it different permissions and looked at different environment variables.

Paul, could you send me a small snippet of your code which works on one machine but not on another?

Pierre, could you do this as well please? Also, what is the root path of the random folder that you mention? i.e. is it c:\Program Files\ or c:\windows or something else?

Regards,

Vince
Vince|Dyalog
 
Posts: 408
Joined: Wed Oct 01, 2008 9:39 am

Re: .NET 4.0 Issues

Postby Tomas Gustafsson on Thu Mar 05, 2015 6:30 pm

.net framework trust levels in:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
Tomas Gustafsson
 
Posts: 101
Joined: Mon Sep 19, 2011 6:43 pm

Re: .NET 4.0 Issues

Postby PGilbert on Fri Mar 06, 2015 1:02 pm

Please look to see if the DLLS are "blocked", this usually happens if they've been downloaded. There's an "Unblock" button on the General Tab of the properties dialog for the file.


Hello Vince, this has done the trick for me. Many thanks.
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: .NET 4.0 Issues

Postby paulmansour on Mon Mar 09, 2015 3:22 pm

Thanks Pierre for confirming this.

And thanks Vince for the solution.

Both unblocking worked, and also changing the dyalog.exe.config file. This was a bit tricky to test, as once you unblock the file, you cannot block it again! (From the general tab anyway). Turns out I had other dlls failing as well, and rather than unblocking I changed the config file and it all worked.

I had originally googled this problem using the error message in the session and did not come up with any solution. Googling "blocked dll" however finds a lot more. Turns out that the dll will be blocked depending on the type of file system and how the file arrived on that system. Apparently if you copy the dll to a flash drive, and then copy it back it will be unblocked. And .... yes that works! When I copied the blocked dll to a flash drive, I got a message saying that the file properties could not be copied along with the file, was I sure I wanted to do it?! I copied it back again and, bingo, unblocked.

Isn't Windows wonderful?

Thanks all again.
paulmansour
 
Posts: 418
Joined: Fri Oct 03, 2008 4:14 pm

Re: .NET 4.0 Issues

Postby Vince|Dyalog on Tue Mar 10, 2015 12:17 pm

Hi Paul and Pierre,

I'm glad that you've both resolved the issues.

I should mention that the unblock suggestion came from JD when I asked him about your issues.

Regards,

Vince
Vince|Dyalog
 
Posts: 408
Joined: Wed Oct 01, 2008 9:39 am

Re: .NET 4.0 Issues

Postby PGilbert on Tue Mar 10, 2015 3:37 pm

Today I got that same error again but this time trying to load a workspace on a remote hard drive that is using a 3rd party dll: (EXCEPTION: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.) This is with Windows 8 and there is no 'UnBlock' button on the dll to click (but there is a button in Windows 7).

Strangely it was working fine the day before and nothing was changed. I have resolved the issue by making a dyalog.exe.config file with an additional element: <trust level="Full"/>
The file looks like this now:
Code: Select all
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
  <runtime>
    <!-- <NetFx40_LegacySecurityPolicy enabled="true"/> -->
    <loadFromRemoteSources enabled="true"/>
    <trust level="Full"/>
  </runtime>
</configuration>


While in administrator mode you can go in Options -> Configure -> .Net Framework and uncheck the Specify .Net Version and when you reboot it is still uncheck and there is no dyalog.exe.config. This is working normally. Now if I add my own dyalog.exe.config file in the dyalog.exe directory when I restart the interpreter the Specify .Net Version is checked and the dyalog.exe.config file that you see is not the one that is in the dyalog.exe directory.

My question is: What is the best procedure to modify the dyalog.exe.config file ?
User avatar
PGilbert
 
Posts: 436
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: .NET 4.0 Issues

Postby Vince|Dyalog on Wed Mar 11, 2015 9:26 am

Hi Pierre,

Thanks for your post with the results of your research.

If you need to customize the dyalog.exe.config, it's best to modify it yourself using a text editor which is "Run as administrator". In this situation, do not use the Options->Configure->.Net Framework page.

Regards,

Vince
Vince|Dyalog
 
Posts: 408
Joined: Wed Oct 01, 2008 9:39 am


Return to Microsoft.NET

Who is online

Users browsing this forum: No registered users and 1 guest