I have installed this InpOut32.dll for programming the parr.port and I have
tested the installation with the included testprogram and it works fine.
Now I will try my own program - and I add only ONE statement - just to try -
but I get an exception.
When I'm commenting the statement out - I gets NO exception - so what's
wrong - here is the exception:
System.Security.SecurityException was unhandled
Message="System.Security.Permissions.SecurityPermission"
Source="KSDivHead"
StackTrace:
at KSDivHead.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()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd,
Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at KSDivHead.Program.Main()
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Best regards
KSor, Denmark
Ignacio Machin ( .NET/ C# MVP ) - 22 Feb 2008 12:40 GMT
Hi,
>I have installed this InpOut32.dll for programming the parr.port and I have
>tested the installation with the included testprogram and it works fine.
[quoted text clipped - 8 lines]
> Message="System.Security.Permissions.SecurityPermission"
> Source="KSDivHead"
Obviously you have some security issue going on. did you check the docs of
the dll to see if yor program needs to request any permission?
Did you check the InnerException of the exception you are getting? In some
instances you get a more especific error there.
Willy Denoyette [MVP] - 22 Feb 2008 12:49 GMT
>I have installed this InpOut32.dll for programming the parr.port and I have
>tested the installation with the included testprogram and it works fine.
[quoted text clipped - 58 lines]
> Best regards
> KSor, Denmark
Tell us what statement you add. (...and I add only ONE statement ) and
please show us some code.
From the stack trace we can only conclude that you have a security issue
(are you sure you are running in full trust?), however it's not clear what
the added statement has to do with this!
Willy.
KS - 22 Feb 2008 13:48 GMT
>>I have installed this InpOut32.dll for programming the parr.port and I
>>have tested the installation with the included testprogram and it works
[quoted text clipped - 15 lines]
> (are you sure you are running in full trust?), however it's not clear what
> the added statement has to do with this!
I'm only trying to output a value to the parr. port with
PortAccess.Output (Address, 0);
And Address has the value 378.
I'm NOT sure I'm running in full trust - what is that ?
KSor, Denmark
Willy Denoyette [MVP] - 22 Feb 2008 14:14 GMT
>>>I have installed this InpOut32.dll for programming the parr.port and I
>>>have tested the installation with the included testprogram and it works
[quoted text clipped - 19 lines]
>
> PortAccess.Output (Address, 0);
You said ...and I add only ONE statement, is this the statement that you
added to the "included testprogram "??
Are you sure that this is the statement that throws the exception?
What else do you have in your Form1_Load method?
Why not trying using a simple console application and post this instead of a
Forms application?
> And Address has the value 378.
>
> I'm NOT sure I'm running in full trust - what is that ?
"full trust" relates to Code Access Security, please consult MSDN for
details.
Are you loading this exe from a local drive?
Willy.
KS - 22 Feb 2008 16:09 GMT
> Are you loading this exe from a local drive?
The only think wrong was I had to place my project on the local drive !
Thanks !
Best regards
KSor, Denmark