Smart Client Fails When Run On Machine With .NET 2.0

K

Kevin

I have a Smart Client application that was written in .NET 1.1 long
before .NET 2.0 ever came out. It works great. It uses web services
and because we have many development environments, it dynamically gets
the base Url to construct the Url for the web services by simply
calling Application.ExecutablePath.

Like I said, this all works great on a computer with .NET 1.1 Framework
installed, but it now fails on a computer that has both .NET 1.1 and
recently installed .NET 2.0! So much for Microsoft's side by side
execution!

The error I get is as follows:
System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
failed.
at
System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(PermissionToken
permToken, CodeAccessPermission demand, StackCrawlMark& stackMark,
Int32 checkFrames, Int32 unrestrictedOverride)
at
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Reflection.Assembly.VerifyCodeBaseDiscovery(String
codeBase)
at System.Reflection.Assembly.GetName(Boolean copiedName)
at System.Reflection.Assembly.GetName()
at System.Windows.Forms.Application.get_ExecutablePath()

I have tried all kinds of things, but trying to get at the launch Url
always fails with the FileIOPermission Security Exception.

I have tried several other things like:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms05152003.asp

But the following returns null:
AppDomain domain = AppDomain.CurrentDomain;
object obj = domain.GetData("APP_LAUNCH_URL");
string appLaunchUrl = (obj != null ? obj.ToString() : "");

And calling:
string configFile = domain.SetupInformation.ConfigurationFile;

Throws the same FileIOPermission Security Exception.

I also tried:
http://www.dotnet247.com/247reference/msgs/44/224782.aspx

But could not get it to work.

If anyone has any ideas they'd like to throw my way, I'd appreciate it.
 
G

Geoff Munday

Are you running the smart client app off of a share on a seperate
machine?

If so, you probably want to verify your runtime security policy
settings on the machine you are executing this code. By default, file
IO is not allowed for code running from mapped drives.

Check your .NET runtime security settings and modify the security
policy if necessary.

Regards,

Geoff
http://nonspect.com
 
K

Kevin

Another strange occurrance that I noticed, well two actually, is that
on the machine with .NET 2.0 Framework installed, when I browse to the
..exe Url, it doesn't even attempt to make a request for the .config
file. On the machine with 1.1 Framework, it makes many requests to try
to resolve everything as is documented.

Here is the only line from the IIS log file that is generated from the
machine with the 2.0 Framework.

2006-06-06 18:06:58 W3SVC1 10.17.2.61 GET /Smart/TestApp.exe - 80 -
10.17.2.135
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727)
200 0 0

And here is everything from the machine that only has 1.1 Framework:

2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET /Smart/TestApp.exe.config -
80 - 10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
404 3 50
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET /Smart/TestApp.exe.config -
80 - 10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
404 3 50
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET /Smart/TestApp.exe - 80 -
10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
304 0 0
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET /Smart/TestApp.DLL - 80 -
10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
404 0 2
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET /Smart/TestApp/TestApp.DLL -
80 - 10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
404 0 3
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET /Smart/bin/TestApp.DLL - 80 -
10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
404 0 2
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET
/Smart/bin/TestApp/TestApp.DLL - 80 - 10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
404 0 2
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET /Smart/TestApp.EXE - 80 -
10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
200 0 0
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET /Smart/TestApp/TestApp.EXE -
80 - 10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
404 0 3
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET /Smart/bin/TestApp.EXE - 80 -
10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
404 0 2
2006-06-06 18:08:47 W3SVC1 10.17.2.61 GET
/Smart/bin/TestApp/TestApp.EXE - 80 - 10.17.2.92
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
404 0 2


The second strange thing I noticed is that I used Process Explorer from
Sys Internals to try to look at all the files it was binding to. Turns
out it was binding to all 1.1 assemblies like mscorlib.dll. But then I
noticed that on the machine with the 2.0 Framework, it no longer uses
the IEExec.exe process!

Now that I'm writing this, I just had another thought. On the 2.0
Framework machine, I am prompted not once, but twice to "Run" the .exe.
You know, one of those standard security warning dialog boxes, "Do you
want to Run or Save?".

So I was thinking that just because the 2.0 Framework is installed, it
only expects you to run the new ClickOnce style of applications.

Any other ideas or confirmation on my findings would be appreciated.

Thanks,
Kevin
 
K

Kevin

Regarding the security settings, I completely agree with you, however,
I think that is missing the point. Why does code written in .NET 1.1
run just fine on a machine that only has the 1.1 Framework installed,
but then fails on a machine that has both the 1.1 Framework and 2.0
Framework installed.

Changing the security settings and allowing the Internet permission set
to have FileIO I'm sure will work, but it is not feasible to go around
to all people's machines and do that.
 
G

Geoff Munday

Well Kevin...that is the point, actually.

I am merely probing because I do not know your particular
setup/deployment details and or how your machine/your user's machines
are configured to enforce security policy (which by the way is the
nature of the error you are receiving).

....and I'm not suggesting you give the "Internet" permission set
"FileIO" - probably a really bad idea.

Also, be sure we are referring to the same thing - the ".NET
Configuration 1.1 Runtime Security Policy" settings that can be
accessed via "Administrative Tools" in the "Control Panel".

Regards,

Geoff
http://nonspect.com
 
G

Geoff Munday

So I was thinking that just because the 2.0 Framework is installed, it
only expects you to run the new ClickOnce style of applications.

I think you might have just answered your own question here.

This is a link to the security portion of the ClickOnce sections on
windowsforms.net. Some good info there; might help you if you decide
to upgrade to that model. Also, I noticed that if you want to run v1.1
apps you do need to create a v2.0 loader. Anyways, good luck.

http://www.windowsforms.net/FAQs/default.aspx?PageID=3&CategoryID=24&SubcategoryID=25&tabindex=2

Regards,
Geoff
 
K

Kevin

Thanks, Geoff. There are some interesting FAQs in that link but I
don't think I will persue any of them. I'll keep trying other things
for a work around. Thanks for the help and suggestions.

Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top