473,796 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 .SecurityExcept ion.
(System.Securit y.Permissions.S ecurityPermissi on)
Status of failed permission:

<IPermission class="System.S ecurity.Permiss ions.SecurityPe rmission,
mscorlib, Version=1.0.500 0.0, Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9"
version="1"
Flags="Unmanage dCode"/>

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

SecurityPermiss ion perm = new
SecurityPermiss ion(SecurityPer missionFlag.Unm anagedCode);
perm.Assert();

Any Ideas?

Regards
Stephan
Nov 23 '05 #1
1 1445
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.co m

"Stephan Zaubzer" <st************ *@schendl.at> wrote in message
news:uS******** ******@TK2MSFTN GP14.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 .SecurityExcept ion.
(System.Securit y.Permissions.S ecurityPermissi on)
Status of failed permission:

<IPermission class="System.S ecurity.Permiss ions.SecurityPe rmission,
mscorlib, Version=1.0.500 0.0, Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9"
version="1"
Flags="Unmanage dCode"/>

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

SecurityPermiss ion perm = new
SecurityPermiss ion(SecurityPer missionFlag.Unm anagedCode);
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
3068
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 explorer would do in this case. The headers I am getting are: Headers {Content-Disposition: attachment; filename="dynamic_file.mdb" Connection: close Cache-Control: private Content-Type: application/octet-stream
1
1595
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 improvement on a very large simulation based system. All my variables are currently encapsulated in public UDTs. If I could access these COM UDTs from a .NET dll, I will be sorted for porting the important engine of the system without having to...
5
2707
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 properties. I want to know if there is a way to access the methods and the properties of the Owner class for the class that's inside it? I.e. I want to find out within Engine what make the Car is which is exposed by the property Car.Model.
2
7857
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 device without having to use the software provided by Lifescan. The software is free and is okay but it's not very good at manipulating the data. Although I connect my meter using a USB cable, it can be connected by a serial cable (there is a...
10
3933
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication eventname string source string ID string
6
5035
by: earthwormgaz | last post by:
Is the following legal? class Outer { class Inner { private: Inner() { } };
1
2136
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 project. However, I don't want to build two different applications for each version; I want my application to detect and use the current version at runtime. But when I load the assembly at runtime, I don't have access to its classes at compile time...
4
1417
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 holding me back from compiling my code. I won't go into detail about the simulation but basically I have a Boat super class and extended from this are the sub classes; cruiser, speedboat, and jetski. My problem is when it comes to accessing...
9
1953
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 only be called by d1, d3, d4 I think I have two options. (1) Make all functions virtual and define them in the required derived classes. This will of course lead to a lot of code duplication and problems in maintainability.
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10465
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4127
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.