Results 1 to 9 of 9

Thread: App crash when reading CommandLineArgs

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    39

    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:
    1. Sub main()
    2.         Dim cmdline As String = ""
    3.         'Dim Args() As String = System.Environment.GetCommandLineArgs()
    4. [B]        For Each Arg As String In My.Application.CommandLineArgs 'Args[/B]
    5.             MsgBox(Arg)
    6.             If InStr(LCase(Arg), APP_NAME) = 0 And InStr(LCase(Arg), DEBUG_APP_NAME) = 0 Then
    7.                 cmdline += Arg & " "
    8.             End If
    9.         Next

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: App crash when reading CommandLineArgs

    when you say it craps out.. it must be throwing an error. so what is the error?

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    39

    Re: App crash when reading CommandLineArgs

    On my test box it says that "An exception 'System.Security.SecurityException" has occured in mmu.exe.

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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

  5. #5
    New Member
    Join Date
    Jan 2007
    Posts
    9

    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?

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  7. #7
    New Member
    Join Date
    Jan 2007
    Posts
    9

    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?

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  9. #9
    New Member
    Join Date
    Jan 2007
    Posts
    9

    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:

    1. Start>Control Panel>Administrative Tools>Microsoft .NET Framework 2.0 Configuration
    2. Expand Console Root>.NET Framework 2.0 Configuration>My Computer
    3. Click Runtime security Policy
    4. Click Adjust Zone Security
    5. Select Make changes to this computer
    6. Click Next
    7. Click Local Intranet
    8. Raise the level to Full Trust
    9. Click Next
    10. Review the new settings (Local Intranet should read Full Trust)
    11. Click Finish

    At this point, your machine is now configured.

    To create an MSI to deploy this security policy to other machines:
    1. You should be at the Runtime Security Policy section
    2. Click Create Deployment Package
    3. Choose the Machine policy level
    4. Browse or enter a file name. I used C:\DOT NET Framework 2.0 Intranet Full Trust Policy.msi
    5. Click Next
    6. 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
  •  



Click Here to Expand Forum to Full Width