?
Solved

Make dot net console application trusted on Local Intranet

Posted on 2008-10-20
10
Medium Priority
?
2,225 Views
Last Modified: 2013-12-17
I have written a console application in C# dot net 1.1 that simply runs a program (robocopy.exe) as another user (Impersonation). The app works fine on my computer. It is supposed to be executed on a shared location (H:\path\app.exe). But when I run it from that direction/path an error message appears saying: "Application has generated an exception that could not be handled".

When I go to administrator tools -> .net wizards -> adjust dot net security and sets the Local Intranet to full trust it works fine.

Is there a way to make my app run under Medium Trust? Signing? Some users are not administrators and cant choose Full Trust.

full-trust.bmp
medium-trust.bmp
errormessage.bmp
0
Comment
Question by:einarbrown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22756003
You need to sign your assembly/exe with a key. I remember fixing a similar problem while back by signing the assembly so it could be executed from a shared folder.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22756151
Because the error is not related to security, it has nothing to do with the level of trust.

Add tracing to your application to find exactly what statement in your code is triggering the error.
0
 
LVL 6

Author Comment

by:einarbrown
ID: 22756867
When I debugging on the shared network drive a get a message thats not handled even though I have try-catched it. When I set the Local Network to Full trust it works. So my guess is that it has to do with the Security Settings.
error2.bmp
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22756945
This other error message is clearly related to security but the first one is not. There is something that makes the application crash.
0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22756993
Debugging probably wouldnt work as the runtime is not allowing your code to execute because it does not have the necesarry permissions.
Have you signed your assembly?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22757019
AmarIs26, if you elevate Trust to Full, you don't have to sign the assembly.
0
 
LVL 6

Author Comment

by:einarbrown
ID: 22757178
If its possible, I rather not change the Trust level.

How do I sing the application? What I have done is made a .snk file and referenced it in AssemblyInfo.cs. Is there something more I should do to sign it? Can I put the .snk file on the shared path or is it compiled into the .exe?
[assembly: AssemblyKeyFile("path\\keyfile.snk")]

Open in new window

0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1000 total points
ID: 22757278
>>I rather not change the Trust level.

If the purpose of not changing the Trust Level is not having to do it on each PC, notice that you will have to trust that signed assembly on each PC.
0
 
LVL 6

Assisted Solution

by:AmarIs26
AmarIs26 earned 1000 total points
ID: 22757386
You can simply configure the signing in the Project Property dialog if you are using visual studio 2005. Right click on the project and  then properties and finally select the Signing tab.
Then it is just the case of checking the sign the assembly checkbox and selecting the key file. We had an app that came up with an error when deployed in the shared folder and signing it fixed that.
I suggest you try that as your first step. If that doesnt work then the next step would be to configure the permissions. Then again you could add Attributes in your code to demand a lower permission or something....
0
 
LVL 6

Author Closing Comment

by:einarbrown
ID: 31507739
Thanks for all your help. Its really been helpful and Im very grateful. Thanks allot!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question