473,653 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

following of thread: "Adding namespaces to code behind automatically"

following of thread: "Adding namespaces to code behind automatically"

Hello,

I had quite the same problem and got further in the right direction
with your suggestions, thanks.
Nevertheless, I have a newer problem which seems to come from the fact
that the
assembly which contains my "SimpleComponen tToolboxItem" must be
already referenced
in the project where I want to insert my control.

I have a usercontrol, which uses a TagListViewTool boxItem and its
CreateComponent sCore
method to reference other assemblies to the project where I insert my
control. like this:
(In the library xyz.dll)
[System.Componen tModel.ToolboxI tem(false)]
[Serializable]
public class MYTagListViewTo olboxItem : ToolboxItem
{
/// <summary>Not used...</summary>
public MyTagListViewTo olboxItem() : base() { }
private MyTagListViewTo olboxItem(Seria lizationInfo info,
StreamingContex t context)
: base(typeof(MyC ontrols.MyTagLi stView))
{
Deserialize(inf o, context);
}

protected override IComponent[]
CreateComponent sCore(IDesigner Host host)
{
MessageBox.Show ("1");
ITypeResolution Service service1;
IComponent component1;
IComponent[] componentArray1 ;
IContainer container1 = host.Container;

service1 =
((ITypeResoluti onService)host. GetService(type of(ITypeResolut ionService)));

string assPath = "C:\\MyAssembli es";
string ass1Name = assPath + "\\log4net.dll" ;
string ass2Name = assPath + "\\Util.dll ";

System.Reflecti on.Assembly ass1 =
System.Reflecti on.Assembly.Loa dFrom(ass1Name) ;
System.Reflecti on.Assembly ass2 =
System.Reflecti on.Assembly.Loa dFrom(ass2Name) ;

service1.Refere nceAssembly(ass 1.GetName());
service1.Refere nceAssembly(ass 2.GetName());

component1 =
(IComponent)Sys tem.Activator.C reateInstance(T ype.GetType(thi s.TypeName));
container1.Add( component1);
componentArray1 = new IComponent[] { component1 };
return componentArray1 ;
}
}
I have the assembly loaded in the VS8 Toolbox and this implementation
works fine when the project
where I want to drag-and-drop the MyTagListView control already has a
reference to my library xyz.dll,
which contains my toolboxitem class.

But if the project does not already reference the xyz.dll assembly, I
get the following error while trying
to insert my control on the form:

"Failed to create component 'Component'. The error message follows:
'The toolbox item could not be retrieved from the toolbox. Make sure
the assembly that contains the
toolbox item is correctly installed. The toolbox item raised the
following error: Object reference not
set to an instance of an object."

.... and my control is not inserted. I thought that this was because
the control type set in the private
constructor was not known by the project. But then I have replaced my
MyTagListView control to a
normal Button control (still in this private constructor, and the
problem still occured. This tells me
that the assembly which contains my toolboxitem MUST be referenced in
the project before being
able to use the control from the toolbox.

I have also put some messagebox in the private method, and found out
that having just the mouse over
the toolboxitem of my control will instanciate my toolboxitem.

If this cannot be fixed, it means that I absolutely need to reference
my xyz.dll assembly to the project before
being allowed to insert my controls in the form. I have tried many
things, and I must say that I am short
of arguments... .

Thank you in advance for your help,

Jean-Francois

Mar 14 '07 #1
1 2394
No idea anyone?


On Mar 14, 9:08 am, "Jedufa" <jed...@gmail.c omwrote:
following of thread: "Adding namespaces to code behind automatically"

Hello,

I had quite the same problem and got further in the right direction
with your suggestions, thanks.
Nevertheless, I have a newer problem which seems to come from the fact
that the
assembly which contains my "SimpleComponen tToolboxItem" must be
already referenced
in the project where I want to insert my control.

I have a usercontrol, which uses a TagListViewTool boxItem and its
CreateComponent sCore
method to reference other assemblies to the project where I insert my
control. like this:
(In the library xyz.dll)
[System.Componen tModel.ToolboxI tem(false)]
[Serializable]
public class MYTagListViewTo olboxItem : ToolboxItem
{
/// <summary>Not used...</summary>
public MyTagListViewTo olboxItem() : base() { }
private MyTagListViewTo olboxItem(Seria lizationInfo info,
StreamingContex t context)
: base(typeof(MyC ontrols.MyTagLi stView))
{
Deserialize(inf o, context);
}

protected override IComponent[]
CreateComponent sCore(IDesigner Host host)
{
MessageBox.Show ("1");
ITypeResolution Service service1;
IComponent component1;
IComponent[] componentArray1 ;
IContainer container1 = host.Container;

service1 =
((ITypeResoluti onService)host. GetService(type of(ITypeResolut ionService)));

string assPath = "C:\\MyAssembli es";
string ass1Name = assPath + "\\log4net.dll" ;
string ass2Name = assPath + "\\Util.dll ";

System.Reflecti on.Assembly ass1 =
System.Reflecti on.Assembly.Loa dFrom(ass1Name) ;
System.Reflecti on.Assembly ass2 =
System.Reflecti on.Assembly.Loa dFrom(ass2Name) ;

service1.Refere nceAssembly(ass 1.GetName());
service1.Refere nceAssembly(ass 2.GetName());

component1 =
(IComponent)Sys tem.Activator.C reateInstance(T ype.GetType(thi s.TypeName));
container1.Add( component1);
componentArray1 = new IComponent[] { component1 };
return componentArray1 ;
}
}
I have the assembly loaded in the VS8 Toolbox and this implementation
works fine when the project
where I want to drag-and-drop the MyTagListView control already has a
reference to my library xyz.dll,
which contains my toolboxitem class.

But if the project does not already reference the xyz.dll assembly, I
get the following error while trying
to insert my control on the form:

"Failed to create component 'Component'. The error message follows:
'The toolbox item could not be retrieved from the toolbox. Make sure
the assembly that contains the
toolbox item is correctly installed. The toolbox item raised the
following error: Object reference not
set to an instance of an object."

... and my control is not inserted. I thought that this was because
the control type set in the private
constructor was not known by the project. But then I have replaced my
MyTagListView control to a
normal Button control (still in this private constructor, and the
problem still occured. This tells me
that the assembly which contains my toolboxitem MUST be referenced in
the project before being
able to use the control from the toolbox.

I have also put some messagebox in the private method, and found out
that having just the mouse over
the toolboxitem of my control will instanciate my toolboxitem.

If this cannot be fixed, it means that I absolutely need to reference
my xyz.dll assembly to the project before
being allowed to insert my controls in the form. I have tried many
things, and I must say that I am short
of arguments... .

Thank you in advance for your help,

Jean-Francois

Mar 20 '07 #2

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

Similar topics

11
2288
by: Dave Smithz | last post by:
Having adopted someone else's PHP cope and completing a crash course in the language I came across a (probably common) problem with the current code. On a registration form, whenever users names have an apostrophe in them it causes problems as they do not get added to the DB correctly for reasons that immediately become apparent. Before implementing my own workaround I noticed the functions. addslashes, stripslashes and directive...
4
1485
by: sparks | last post by:
As you might know that "java.lang" package are automatically imported by the java compiler so that one don't need to write the import statement of that package in the source code. Are there any packages in .net are automatically "used" when your are writing a .net application? I am told that Visual Studio ..net automatically include different packages depending on the kind of applications you are creating. is this true? Will the compilier...
1
3497
by: | last post by:
Hi guys! I am a beginner with aspx (i have some background with .asp). And i am trying tu use a 'code-behind' page in order to execute all transactions in that page and leave as clean as possible the .aspx with the html. As my start-point, i am building a login page. I put the textbox and submit button on the page index.aspx; and, i put all the db validation on the page maquinaria.vb. on index.aspx i have this button:
1
1296
by: Girish | last post by:
I understand that the code behind concept is a framework that separates code logic from visulization code. I belive this is true for pages that are mostly static. Ie. Forms elements on a page that are fixed in number. What if i had a requirement that involves a highly dynamic page, with a dynamic number of form elements based on various user selections. I cant see how I cant separate code that splits the "form generation logic" as a...
1
1375
by: Zack Sessions | last post by:
Running VB.NET 2003. I have an application that is a "client/server" type application. The VB.NET code depends on a set of stored procedures to do some of the more complex SQL stuff. I have a script that installs all the stored procs and related tables. Can I have this script run automatically during the installation of the VB.NET app? I do have an Installation Project defined for the app. TIA,
1
5323
by: Laurent Bugnion | last post by:
Hi, I am trying to programatically add an "onunload" event handler to the "body" tag of an ASPX page. I am doing this from a Custom Control located on this page. To do this, I added "runat=server" to the body tag, which provides me access to it in the code-behind through a HtmlControl. I can then manipulate the Attributes collection, which is what I needed. So far so good.
6
6009
by: Nathan Sokalski | last post by:
I recently converted some ASP.NET 1.1 projects of mine, created with Visual Studio .NET 2003, to Web Application Projects in Visual Studio .NET 2005 so that I could use ASP.NET 2.0 (All my ASP.NET is done using VB.NET). After converting, everything was fine, and worked and compiled correctly, but I noticed one big difference between the VB.NET code of the converted files in the projects and the VB.NET code in new pages. The new pages use...
2
1601
by: Yujo | last post by:
Hello everybody, In the following code of the finish() function, is there any way to get the exit code passed to sys.exit() ? def finish() : RETURN_CODE_FROM_SYS_EXIT = ???? # how can I get it ? if RETURN_CODE_FROM_SYS_EXIT = 0 : # process ended OK else :
3
4251
by: Begreen | last post by:
Hi All, I wrote a java program which outputs a xml file! But I would prefer this program to insert the DTD code on the fly, in the xml file when created! I want the xml file to look like this:
0
8370
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
8283
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
8811
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...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
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,...
1
6160
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
5620
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2707
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

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.