473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Accessing com classes from c#

Hi
I relatively new to C# and at the moment I am having troubles accessing
com objects within C#.
I am working in VS.net. I add the com library I want to access to my
references. Accessing classes exported in this com interfaces will throw
a System.Security.SecurityException.
(System.Security.Permissions.SecurityPermission)
Status of failed permission:

<IPermission class="System.Security.Permissions.SecurityPermiss ion,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Flags="UnmanagedCode"/>

I also tried inserting the following code before trying to call
unmanaged code, but with no success.

SecurityPermission perm = new
SecurityPermission(SecurityPermissionFlag.Unmanage dCode);
perm.Assert();

Any Ideas?

Regards
Stephan
Nov 23 '05 #1
1 1429
Stephan,

Where are you running this application from? Is it an ASP.NET
application, or are you running it from the web, or a network share?

In any of these situations, you are not given permissions to run
unmanaged code. This is why your calls are failing, most likely.

If this is the case, to fix this, you have to go to the .NET framework
administration tool (it's under administrative tools) and change the
permission sets for the app (based on it's hash, a strong name, or other
identifier) so that you have unmanaged code permission.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Stephan Zaubzer" <st*************@schendl.at> wrote in message
news:uS**************@TK2MSFTNGP14.phx.gbl...
Hi
I relatively new to C# and at the moment I am having troubles accessing
com objects within C#.
I am working in VS.net. I add the com library I want to access to my
references. Accessing classes exported in this com interfaces will throw a
System.Security.SecurityException.
(System.Security.Permissions.SecurityPermission)
Status of failed permission:

<IPermission class="System.Security.Permissions.SecurityPermiss ion,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Flags="UnmanagedCode"/>

I also tried inserting the following code before trying to call unmanaged
code, but with no success.

SecurityPermission perm = new
SecurityPermission(SecurityPermissionFlag.Unmanage dCode);
perm.Assert();

Any Ideas?

Regards
Stephan

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Daniel Corbett | last post by:
I am trying to save a file dynamically created in a webpage. I get the following headers, but cannot figure out how to save the attachment. I am basically trying to replicate what internet...
1
by: jimfollett1 via DotNetMonster.com | last post by:
Hey all, I was wondering if you could put me out of my misery (hopefully, not literaly) .. I am currently trying to port some VB6 code to VB.NET because of a possible significant performance...
5
by: Cyril Gupta | last post by:
Hello, I have a class inside another class. The Scenario is like Car->Engine, where Car is a class with a set of properties and methods and Engine is another class inside it with its own set of...
2
by: Jimmy Reds | last post by:
Hi, I have a blood glucose meter (a Lifescan OneTouch Ultra in case anyone was wondering) which I connect to my PC using a USB cable and I would like to have a go at accessing the data on this...
10
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication...
6
by: earthwormgaz | last post by:
Is the following legal? class Outer { class Inner { private: Inner() { } };
1
by: zumbo | last post by:
I'm accessing MSOutlook via Microsoft.Office.Interop.Outlook. It works fine if I add a reference to either version 11 (Outlook 2003) or version 12 (Outlook 2007) of the interop assembly to my...
4
by: GesterX | last post by:
Hi guys, this has been bugging me for a while and I'd appreciate any help anyone could offer. Basically I am running a boating simulation and I have all of the "harder" parts done but one error is...
9
by: fgh.vbn.rty | last post by:
Say I have a base class B and four derived classes d1, d2, d3, d4. I have three functions fx, fy, fz such that: fx should only be called by d1, d2 fy should only be called by d2, d3 fz should...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.