Why "Permission denied", How to fix it?

F

FD

A COM was used in VBscript and worked fine.
Now I try to use C# to call it with following code:

Type myType = Type.GetTypeFromProgID("MyProgID");
object myObj = Activator.CreateInstance(myType);
Object myResult = myType.InvokeMember("MyFunction",
BindingFlags.DeclaredOnly | BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.InvokeMethod, null, myObj,
new Object[] {myParam});

The 3rd line code got an error: "Permission denied".

Any idea, how fix it?
Thanks,
FD
 
V

Val Savvateev

Try to play with different sets of BindingFlags. I wonder if removing
"NonPublic" would help...

Val.
 
W

Willy Denoyette [MVP]

FD wrote:
|| A COM was used in VBscript and worked fine.
|| Now I try to use C# to call it with following code:
||
|| Type myType = Type.GetTypeFromProgID("MyProgID");
|| object myObj = Activator.CreateInstance(myType);
|| Object myResult = myType.InvokeMember("MyFunction",
|| BindingFlags.DeclaredOnly | BindingFlags.Public |
|| BindingFlags.NonPublic | BindingFlags.Instance |
|| BindingFlags.InvokeMethod, null, myObj,
|| new Object[] {myParam});
||
|| The 3rd line code got an error: "Permission denied".
||
|| Any idea, how fix it?
|| Thanks,
|| FD

What's the identity/security context of the user running this code (aspnet or other)?
What does MyProgID refer to (exec server or a DLL)?

Willy.
 
F

FD

-----Original Message-----
FD wrote:
|| A COM was used in VBscript and worked fine.
|| Now I try to use C# to call it with following code:
||
|| Type myType = Type.GetTypeFromProgID("MyProgID");
|| object myObj = Activator.CreateInstance(myType);
|| Object myResult = myType.InvokeMember("MyFunction",
|| BindingFlags.DeclaredOnly | BindingFlags.Public |
|| BindingFlags.NonPublic | BindingFlags.Instance |
|| BindingFlags.InvokeMethod, null, myObj,
|| new Object[] {myParam});
||
|| The 3rd line code got an error: "Permission denied".
||
|| Any idea, how fix it?
|| Thanks,
|| FD

What's the identity/security context of the user running this code (aspnet or other)?
What does MyProgID refer to (exec server or a DLL)?

Willy.


.

This is a aspnet app to call "MyProgID" - which is a VB6
dll and was registered.
Did I miss some setting?
Thanks,
FD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top