Problem creating wrapper



  • 1. Dropdownlist
    Hi All I'm creating an application and I want to add images to a dropdownlist in using C#. Can anybody help me with this plz. Koen
  • 2. Exception during setting of properties
    I am finishing up work on a custom treeview control that has a Nodes property. Each TreeNode in the collection also has a Nodes property. If I add any nodes to a root level node with the designer, a null reference exception is thrown. The tags for the nodes are created correctly. This exception is not thrown at runtime. I also have made sure to wrap any access to runtime-only objects in if blocks to prevent their access during design. I'm not sure what (if any) code may be helpful in resolving the problem, but my main question is: Does anyone know of a way to get a stack trace at design time for a custom component? The null reference exception message in a message box doesn't really help me in trying to track down and eliminate the bug. Any help would be greatly appreciated!
  • 3. Building controls to work in VS.NET IDE
    I have a customised class which inherited from the ASP.NET webcontrol (e.g. a textbox), now I have add in a few properties into this class, and a few simple script into it. I have build this control, and add it into the Visual Studo.NET IDE toolbox. I am wondering how could I add features like, wizard for this web control, just like the way which ChartFx and Infragistics do. After you drag the component from the toolbox to the design page, we could call up a wizard to setup the new component. I appreciate if anybody could help. Thanks. -- Regards, Wei Chung, Low

Problem creating wrapper

Postby svanrees » Sat, 08 Jan 2005 15:42:41 GMT

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
		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
Thank you very much

Similar Threads:

1.Problem creating C# interop wrapper manually

2.Problems creating COM wrapper for C# dll (regasm.exe)

I called regasm.exe /tlb CameraManagement.dll and I got

When I look inside with OleView.exe or create C++ header  I see
something like that:

struct __declspec(uuid("37944845-f74f-3999-b972-d42355a78bcd"))
_AlarmSetting : IDispatch

struct __declspec(uuid("5e6abb0e-b170-377d-9902-20bb5388a53c"))
_AlarmSetting2 : IDispatch

struct __declspec(uuid("8969367c-f590-333c-994e-c0b2a37ce928"))
_Camera : IDispatch

they're just empty interfaces, only enums are exported correctly - but
oryginal C# classes have plenty of methods ! Where have they gone ? Am
I missing something ?

Thanks in advance

3.Problem creating web service wrapper for VB6 COM DLL that calls C++ DLL


I'm trying to wrap an existing VB 6 COM DLL as a VB.NET 2003 web
service.  I was able to create web methods for each of the COM DLL's
methods I want to expose, but the one method in the COM DLL that
subsequently calls a C++ DLL fails.  I get an error from the VB6 DLL:
ERROR: (453) Can't find DLL entry point PPD in MyDLL32.dll

The same method call works fine if I call the COM DLL from a compiled
VB6 client application.

I get the same DLL entry point error if I try to use the client VB6 app
in the VB6 IDE (COM DLL is alway compiled, never run in the VB6 IDE).

I'm not sure if VB.NET web services behave the same as the VB6 IDE in
some way, but essentially, I need find a way to make it work.

Any suggestions (other than re-write the C++ DLL) will be appreciated.


4.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
      void SetUnmanagedB( UnmangedClassB* val );
__gc class ManagedClassA
     MangedClassA() :
       m_unmanagedA(__nogc new UnmanagedClassA() )
     { }

     __nogc UnmanagedClassA* m_unmanagedA;

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

     __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

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

     __nogc UnmanagedClassB* m_unmanagedB;

   __nogc class NestedFriendClass
        NestedFriendClass( ManagedClassB* owner)
           m_owner = gcroot<ManagedClassB*>(owner);
        UnmanagedClassB* GetUnmanagedB()
           return m_owner->m_unmanagedB;
        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

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.

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


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?


6. Creating a Wrapper

7. How to create COM wrapper for IDataObject & IAdviseSink

8. How to create COM wrapper for IActiveDesktop

Return to ASP.NET


Who is online

Users browsing this forum: No registered users and 76 guest