Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

how to remove message Access denied on creating new object

hello dear,

i am learning component development in C#.i create my own class library with name HelloWorl.Dll.
in this, i create a class MyComponet. i am using it in window based application in C#.
by including all rererences System.EnterpriseServices and Dll file. but when i create new object of that component it will give Exception
Acess is Denied on this line
HelloWorld.MyComponent obj = new HelloWorld.MyComponent();

And in stack trace. it give the information.

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at System.EnterpriseServices.Thunk.Proxy.CoCreateObject(Type serverType, Boolean bQuerySCInfo, Boolean& bIsAnotherProcess, String& uri)
at System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(Type serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props, Boolean bNewObj)
at HelloClient.Form1.cmdWakeUp_Click(Object sender, EventArgs e) in d:\ankush\books\course cds\bulding com+ application\practices\cs\mod02\solution\helloclient\form1.cs:line 104

So plz help me how i can use my Dll file and remove this Exception.

waiting for ur reply......

Ankush
[1386 byte] By [ankushbindra] at [2007-11-11 7:19:54]
# 1 Re: how to remove message Access denied on creating new object
"c:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin"\tlbimp.exe "the path of your dll" /out:new dll name /namespace:<any namespace you want>

This tlbimp.exe is a part of the SDK and is read Type LiBrary IMPort utility also
A dll of written in a platform other than .Net can be wrapped around with a .Net class

The resulting dll is something you can reference directly and start using it

If that still gives the same error , there is something wrong with your dll..

refer tlbimp /? at th VS.net command prompt
srinivas_s at 2007-11-11 21:49:12 >