reading commandlines arguments

pckm_123

Newcomer
Joined
Aug 4, 2003
Messages
7
I have program written in VB.Net.
the program is form based
I'm calling myvbnet.exe from the other program, let's say another c++ program.

I have following code in myvbnet.exe
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim arg1 As String =  ReadCommandLine()
End Sub

Function ReadCommandLine() 
 Dim arg1 As String
arg1 = Environment.CommandLine
ReadCommandLine = arg1
End Function

I used ShellExecuteEx to call myvbnet.exe and pass the argument

but I got the following very long error message
Code:
the application attempted to perform an operation not allowed by the security policy. The operation required the SecurityException . To grant this application the required permission please contact your system administrator, or use the Midrosoft.NET security policy administration tool. 

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Security.SecurityException: Request for the permission of type 
System.Security.Permissions.EnvironmentPermission, 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 Microsoft.VisualBasic.Interaction.Command()
   at PrintMSOF.Form1.GetFileType(String& tempStr)
   at PrintMSOF.Form1.Form1_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()

I got the same message even after taking the line
arg1=Enviroment.CommandLine

How can I call VB.Net Program with arguments from my C++ program?
 
Back
Top