Unable to Create Wrapper

dotnet framework

    Next

  • 1. .net user control as ActiveX Component
    Hello, I created an .net user control and want to use it in an development environment that doesn't directly support .net user controls, so I have to use a COM Interop instead. I registered the dll in the system with VSDotnet and imported it in the development environment, but it is only realized as an Class Library and not as an graphical component. - Has anyone made something similar (ie. .net user control embedded in VB6 Programm)? - Can anyone give me some hints what to consider when making user controls as dll's (what interfaces to extent - how to export and register it in the system)? Thanks Chris
  • 2. Type libraries for static dll functions
    Hi all i have a Dll file which has got a tlb file which i can directly reference in VB6. how to make use of the tlb in C# or vb.net. if i use the tlbimp only the enum and const are imported and none of the static functions. i know i can make use of P/Invoke but it is giving problems .any way out ??
  • 3. how to free string in C# which is allocated by unmanaged code by SysAllocString()
    In C++, I have: ====================== EXPORT_API int GetUniText(..., BSTR* pbsDestText) { int iOutLen = 0; BYTE* buf = NULL; //process to get data buffer //copy to output string *pbsDestText = SysAllocStringLen((OLECHAR*)buf, iOutLen ); return wcslen(*pbsDestText ); } In C#, I have: ====================================== internal class Win32 { [DllImport("MyDll.dll", CharSet = CharSet.Unicode)] public static extern int GetUniText(..., ref string dstText); } public int GetUniText(..., ref string outStr) { int iRet = Win32.GetUniText(..., ref outStr); //use the gotten string //How to free it - ??? return iRet; } I can get the string correctly in C# code. But should I free it by call SysFreeString, or Marshal.FreeBSTR? How to do it? Thank you very much! -jeff
  • 4. CCW question
    Hi, how can I call existing .Net class from COM client? Speccifically i need to connect to existing instance of .Net control from another process. I try IAccessible interface, but it seems that there is no way to queryinterface to another interface than IDispatch, IEnumVariant, IOleWindow, IServiceProvider and IAccIdentity. Is there some special service provider id to obtain CCW wrapper? Can i obtain CCW for existing .Net class and marshal to another process? Thanks Daniel
  • 5. How to get the name of the calling program
    Hello everybody, I've implemented an .net assembly in C#. My assembly can also be used by VB6.0 and C++ written objects, because it has a COM interface. Now I've been searching for a method to get the name/path of the object which is calling me. I've already tried Assembly.GetEntryAssembly().Location and Assembly.GetEntryAssembly().Name but these methods don't work if an VB6.0 object is calling me..... Thanks, Frank

RE: Unable to Create Wrapper

Postby Sm9obiBQYXVsLiBB » Tue, 10 Aug 2004 18:47:03 GMT

Dear Fernandez,
TLBIMP.EXE utility is applicable only for COM DLLs.
To use Win32 DLLs in your code, use DLLImport in your code.
Regards,
John





RE: Unable to Create Wrapper

Postby RmVybmFuZGV6 » Tue, 10 Aug 2004 19:45:02 GMT

Dear John,
Can you please give me an example..







RE: Unable to Create Wrapper

Postby Sm9obiBQYXVsLiBB » Tue, 10 Aug 2004 20:09:02 GMT

Dear
1> Import using this line 
[DllImport("DLLName.dll")]

2> Explicitly declare the functions in the DLL.
public static extern int AddOrRemove(int nLeft, int nRight, char cSymbol);

3> Directly call the DLL Function as
txtresult.Text = 
Convert.ToString(AddOrRemove(Convert.ToInt16(txtvaluea.Text),Convert.ToInt16(txtvalueb.Text),'+'));

Hope you got right now..

Thanks & Regards,
John Paul. A
MCP








Similar Threads:

1.unable to create the offline cache location when trying to create a

The vs.net application is running on my local machine and im trying to
create the project on a remote server.  It gives me the above error
saying the volume lable or syntax is incorrect.  Which is
understandable because it can't create a folder with that name but why
can't i make it work.  HELP!  This is very frustrating.

2.unable to create the offline cache location when trying to create a new project

unable to create the offline cache location when trying to create a
new project.

The vs.net application is running on my local machine and im trying to
create the project on a remote server.  It gives me the above error
saying the volume lable or syntax is incorrect.  Which is
understandable because it can't create a folder with that name but why
can't i make it work.  HELP!  This is very frustrating.

3.Giving one managed wrapper class access to the unmanged part of another managed wrapper class

Here is the scenario I'm trying to make work.

I've got 2 managed C++ classes, each of which wrappes an unmanaged C++
class, kind of like so:

__nogc class UnmanagedClassA
{
   public:
      void SetUnmanagedB( UnmangedClassB* val );
...
};
__gc class ManagedClassA
{
   public:
     MangedClassA() :
       m_unmanagedA(__nogc new UnmanagedClassA() )
     { }

   private:
     __nogc UnmanagedClassA* m_unmanagedA;
};

__nogc class UnManagedClassB
{
...
};
__gc class ManagedClassB
{
   public:
     MangedClassB() :
       m_unmanagedB(__nogc new UnmanagedClassB() )
     { }

   private:
     __nogc UnmanagedClassB* m_unmanagedB;
};

The managed wrapper classes were created to allow using the unmanaged
classes in C#.

I need to be able to hand an instance of ManagedClassB to ManagedClassA
and have it pass the m_unmanagedB pointer to a method of m_unmanagedA.
Something like this:

void ManagedClassA::SetManagedB( ManagedClassB* b )
{
   m_unmanagedA->SetUnmanagedB( b->m_unmanagedB );
}

My first question is: what is the best way to accomplish this task
(idealy without making m_unmangedB public)? and my second question is
why doesn't my solution below work?

Below is my solution that doesn't quite work:

In traditional C++ I would simply declare ManagedClassA as a private
friend of ManagedClassB and everything would be good, but I have come
to the understanding that friends aren't allowed in managed C++ so I've
created a unmanged nested class to solve the problem, something like
this

__gc class ManagedClassB
{
   public:
     ManagedClassB() :
       m_unmanagedB(__nogc new UnmanagedClassB() )
     { }

   private:
     __nogc UnmanagedClassB* m_unmanagedB;

   public:
   __nogc class NestedFriendClass
   {
     public:
        NestedFriendClass( ManagedClassB* owner)
        {
           m_owner = gcroot<ManagedClassB*>(owner);
        }
        UnmanagedClassB* GetUnmanagedB()
        {
           return m_owner->m_unmanagedB;
        }
     private:
        gcroot<ManagedClassB*> m_owner;
   }
};

And the MangedClassA::SetManagedB() method becomes something like.

void ManagedClassA::SetManagedB( ManagedClassB* b )
{
   ManagedClassB::NestedFriendClass temp( b );
   m_unmanagedA->SetUnmanagedB( temp.GetUnmanagedB() );
}

Now this all compiles fine but when I run it I get a
'System.FieldAccessException' exception in
ManagedClassB::NestedFriendClass::GetUnmanagedB().

Now this implies to me that the public, protected, and private access
specifiers are being enforced at run time for unmanaged code which is
surprising to me, can anyone tell me what's going on here.

I will admit that I'm relatively new to the managed C++ and C# worlds
so I may be missing something simple here. I do consider myself a very
advanced traditional C++ programmer.
Also I'm currently using MS Visual Studio 2003.NET and we are upgrading
to 2005.NET next week.

4.creating data provider (IBindingList, DataTable wrapper) for DataGrid?

hello.

i'm trying to implement IBindingList to wrap DataTable
(like DataView) with hierarchy capabilities
and bind it to DataGrid.
The problem is i don't know
yet all the stuff i need to know.
the current problem - what should i return in the
IList[int index] indexer?
definetely not DataRow object.

could i find somewhere tutors, samples?

alex.



5.Problem creating wrapper

Hi
I have been asked by our web host to build a wrapper for a third party
component we wish to use on our web application.
The reason behind this was so I could add the two following lines:
[assembly: AssemblyKeyFileAttribute(@"..\..\keyPair.snk")]
[assembly: AllowPartiallyTrustedCallersAttribute()]
and they will then store my wrapper in the GAC and my Application will
access the component using my trusted wrapper.


I have never built a wrapper before and I am getting the following
error when I attempt to view the page with my component/wrapper on it:

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error: 
Line 13: 	<body MS_POSITIONING="GridLayout">
Line 14: 		<form id="Form1" method="post" runat="server">
Line 15: 			<cc1:TestButton id="TestButton1" style="Z-INDEX: 101;
LEFT: 200px; POSITION: absolute; TOP: 48px" <-THIS LINE
Line 16: 				runat="server"></cc1:TestButton></form>
Line 17: 	</body>

All that i have done is place my component on the form (no code) and
set the licence key in the Global.asax.cs file (code here, but this
part seems to work fine).

The error is probably because I have no idea how to write a wrapper,
so here is the code for my wrapper. (It is a web control library)

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace ButtonComponent
{
	[DefaultProperty("Text"),
		ToolboxData("<{0}:TestButton runat=server></{0}:TestButton>")]
	public class TestButton : Xceed.Chart.Server.ChartServerControl
	{

		static public void SetKey()
		{
			Xceed.Chart.Server.Licenser.LicenseKey = "xxx";
		}
	}
}

All that i want the wrapper to do is allow me to access the regular
functions and properties of ChartServerControl component, so I thought
that this would do, obviously I was wrong.
I really have no idea what i am doing, so any help would be greatly
appreciated.
Thank you very much
Stephen

6. Creating a Wrapper

7. How to create COM wrapper for IDataObject & IAdviseSink

8. Problem creating C# interop wrapper manually



Return to dotnet framework

 

Who is online

Users browsing this forum: No registered users and 72 guest