|
-
May 9th, 2006, 01:24 PM
#1
Thread Starter
Member
App crash when reading CommandLineArgs
I've had a bug in my app that has been a pain to figure. When I compile on my local machine and run there it works fine. When I run on other boxes, it craps out when reading the args. The same thing happened when using both System and My methods for getting command line args.
Any suggestions?
VB Code:
Sub main()
Dim cmdline As String = ""
'Dim Args() As String = System.Environment.GetCommandLineArgs()
[B] For Each Arg As String In My.Application.CommandLineArgs 'Args[/B]
MsgBox(Arg)
If InStr(LCase(Arg), APP_NAME) = 0 And InStr(LCase(Arg), DEBUG_APP_NAME) = 0 Then
cmdline += Arg & " "
End If
Next
-
May 9th, 2006, 01:29 PM
#2
Re: App crash when reading CommandLineArgs
when you say it craps out.. it must be throwing an error. so what is the error?
-
May 9th, 2006, 01:34 PM
#3
Thread Starter
Member
Re: App crash when reading CommandLineArgs
On my test box it says that "An exception 'System.Security.SecurityException" has occured in mmu.exe.
-
May 9th, 2006, 01:43 PM
#4
Re: App crash when reading CommandLineArgs
you aren't trying to run it from a network drive are you?
Also, the MSDN says
My.Application.CommandLineArgs property needs EnvironmentPermission
You can find more information here
http://msdn2.microsoft.com/en-US/library/z2d603cy.aspx
-
Mar 28th, 2007, 10:58 AM
#5
New Member
Re: App crash when reading CommandLineArgs
I am trying to run from a network drive. I knew how to fix this in .NET 1.1, but the .Net Config tool isn't the same. How does one fix this in 2.0?
-
Mar 28th, 2007, 11:07 AM
#6
Re: App crash when reading CommandLineArgs
You have to run CASPOL from a command line to elevate the security for local intranet to full trust. CASPOL comes with the .NET framework, so any machine with the .NET 2.0 framework should have it. Its a little cryptic to use at first though, because it is all command line driven.
The utility in the control panel to do this like you did in .NET 1.1 is not there anymore unless you install the .NET 2.0 SDK (not the Visual Studio IDE, just the SDK)
Why they changed this I don't know.
-
Mar 28th, 2007, 11:10 AM
#7
New Member
Re: App crash when reading CommandLineArgs
Then I guess I need to install the SDK so that I can create the MSI so that I can distribute the settings?
-
Mar 28th, 2007, 11:17 AM
#8
Re: App crash when reading CommandLineArgs
depends on what we are talking about here.
If you have visual studio on your machine, then you already have the SDK. If you go into control panel -> administrative tools, you will see the option to configure security for .NET 2.0
However an end user machine won't have this configuration in the control panel unless they have at least the SDK installed, or the full IDE.
Since that is kind of a crazy option for and end users PC, I recommend you just learn caspol, and run that on the machines that need it.
I suppose it might be possible to build it into a MSI file, but I personally use INNO setup for my installations, and when I do that, I run caspol through my INNO setup code.
Here are the command lines that SHOULD set full trust on a machine for a given network directory.
C:\windows\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -q -machine -remgroup "GroupNameHere"
c:\windows\Microsoft.NET\Framework\v2.0.50727\CasPol.exe -q -machine -addgroup 1.2 -url ""file://f:/yourdirectory/*"" FullTrust -name "GroupNameHere"
replace GroupNameHere in both lines with something to ID your app, maybe the name of it (it can be whatever you want though)
replace f:/yourdirectory with the actual path of the network exe
The reason I run the remove line first, is because if you don't and the user installs or runs this more than once, it will create multiple entires. So that just ensures if they have an existing entry, delete it before recreating it.
-
Mar 28th, 2007, 12:12 PM
#9
New Member
Re: App crash when reading CommandLineArgs
Okay, here's how I did it in .NET 1.1 and this also works in .NET 2.0. Like mentioned above, the .NET 2.0 Config tool is not installed with the framework, so do this from your development machine. You'll need local admin rights.
To set the Local Intranet Zone to Full Trust:
- Start>Control Panel>Administrative Tools>Microsoft .NET Framework 2.0 Configuration
- Expand Console Root>.NET Framework 2.0 Configuration>My Computer
- Click Runtime security Policy
- Click Adjust Zone Security
- Select Make changes to this computer
- Click Next
- Click Local Intranet
- Raise the level to Full Trust
- Click Next
- Review the new settings (Local Intranet should read Full Trust)
- Click Finish
At this point, your machine is now configured.
To create an MSI to deploy this security policy to other machines:
- You should be at the Runtime Security Policy section
- Click Create Deployment Package
- Choose the Machine policy level
- Browse or enter a file name. I used C:\DOT NET Framework 2.0 Intranet Full Trust Policy.msi
- Click Next
- Click Finish
-Give it to your Network Admin for deployment via SMS or GPO
-Requires admin level perms to install
Deployment command line:
Code:
msiexec /i "DOT NET Framework 2.0 Intranet Full Trust Policy.msi" /qb! /lv:"%windir%\DOT NET Framework 2.0 Intranet Full Trust Policy.log"
This is somewhat documented at http://msdn2.microsoft.com/en-us/lib...6y(VS.80).aspx
This is excellently documented at the now defunct gotdotnet site. From Google cache: http://209.85.165.104/search?q=cache...lnk&cd=1&gl=us
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|