1

I've got an existing asp.net project written in vb.net. Another person has written a user control in c#.

Could you please let me know the steps for adding that C# user control to the vb.net app?

I've tried copying them to the folder and using "Add existing item", however it doesn't compile the code behind at all.

Thanks, Fidel

4 Answers 4

2

create a new asp.net user control library project with c#, add C# user control to that project, than in your visual basic project add reference to that library and that's it ;)

Sign up to request clarification or add additional context in comments.

Comments

1

You could use this tool to add the control to the VS toolbox.

An example of usage (choose either /vs2005 or /vs2008 depending on your VS version):

TOOLBOX.EXE [/vs2005] [/vs2008] /installdesktop assembly tabname

Comments

0

The C# control will need to be in a seperate dll. You can then add a reference to this dll in your vb project. Then register the control in the page directive or web.config, like normal.

Comments

0

Just wanted to add another way to accomplish this, as I was just about to ask a question regarding this topic and figured out the solution.

If you truly need to bring over the raw user control files into a new project, you will find simply adding them via 'Add -> Existing Item...' will make each file come into the solution independently and not structure them properly in Solution Explorer.

The trick is to open up the (2) associated user control code files outside of VS.NET prior to adding to your solution and modify thier namespace to be that of your new project. So if in the old project your namespace was:

MyOldProject.CustomControls

...you will want to rename in the .cs and .Designer.cs to the following:

MyNewProject.CustomControls

Then when you go back into VS.NET add add all of the existing items, they will be in their proper arrangement as follows:

MyControl.cs
-->MyControl.Designer.cs
-->MyControl.resx
-->MyControl

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.