C# Assembly Reference problems - c#

I will surely go mad if I don't know what is the reason for this :) :
I have several projects in my solution. The problem I'm getting is in a solution where I'm adding reference of another.
In 1 project I have my custom controls (purely .cs files) and another solution is test pages which are only ASPX pages (without any code behind file - since the entire operation is performed by the controls)
Now the problem is when I added the reference of my Custom Controls project to my Web pages project, the code which I wrote in custom control is not getting affected. I added a new property for my custom textbox control which is not coming in the intellisense in my HTML markup and the break point I'm setting is not getting a hit (inside custom controls code).
This is working fine in .NET 3.5 Framework. (We have 2 branches; one is 3.5 and another is 4.0) but is NOT working in .NET Framework 4.0. I'm using Windows 2008 Server R2.
What I have did uptil now:
Checked the target framework for both the projects (4.0 for both).
Copied and pasted the assembly where ever required.

Try adding your "Custom Control" to ASP.NET project Toolbox panel in Visual Studio (It worked for me once!).

Are the reference project's dll falling in bin folder after build/rebuild?
Have you registered your control in your ASPX page?
Also, when you are saying you have reference to project then what is the reason behing copying and pasting?

Related

ASP.NET Web Application (w/ ascx WebUserControl) as NuGet Package

I'm rather familiar with creating NuGet packages for class libraries. Yesterday i tested doing the same for a ASP.NET Web Application, and to my surprise it worked (kind of - with some quirks).
My Web Application is simple and only contains a single .ascx WebUserControl. My hope was that at the end i would have a DLL containing my control similar to if you were to publish the site and extract the results DLL for the control from the bin of the published site. However this is not quite what happens.
After packing the NuGet package and then using it in other projects, doing so results in the .ascx files fully being "copied" to the project with the NuGet package installed. This .ascx files from the NuGet package can be edited as a normal .ascx file would allow and still references code behind that doesn't exist in the solution.
So there are some issues. My question is - does anyone know of a procedure i can follow that would compile a user control into a DLL that can then be distributed via a NuGet package?
does anyone know of a procedure i can follow that would comile a user control into a DLL that can then be distributed via a NuGet package?
You can convert your usercontrols into custom control, here is a detail document about how to do it.
Turning an ascx user control into a redistributable custom control
The basic steps to make this happen are as follows:
Write your User Control as you normally would, typically using the Visual Studio designer.
Test it using a simple page before trying to deploy it.
Deploy the app to precompile it.
Grab the user control’s assembly produced by the deployment step, and you’re essentially done: you have your Custom Control.
Finally, use your Custom Control in other apps the same way as you always use Custom Control’s.
After compile the user control into a DLL, distributed it via a NuGet package should be easy for you.
Hope this can give you some help.

Prevent Visual Studio 2013 build from upgrading certain Telerik dlls automatically

How to prevent updating certain telerik dlls in Visual Studio 2013?
I am trying to prevent Telerik.Web.UI.dll from upgrading to a different version with a different version timestamp because I have some legacy code that is causing issues so sticking with the existing version is preferable. The same issue existing for Telerik.Web.UI.Skins.dll with the same version numbers (see below).
Working version is 2011.3.1305.35 and the Non-Working version is 2015.3.1111.45
I don't know if I need to load the 2011 version on my computer and also have the 2015 version in the toolbox at the same time to make it an optional compile.
Is it also possible to prevent this from updating when I first load up the visual studio project? Finally is it possible to keep the current version of Telerik control panel settings and without reverting to older version of the control panel just keep current settings?
To fix for my case: Right Click the Project in solution explorer that contains the dlls. Then Update the Property Pages by removing the "Auto Update" versions for both Telerik.Web.UI.dll and Telerik.Web.UI.Skins.dll by selecting them and then hitting the "Remove" button under the Reference section which should be the top most section in "Property Pages".
This would probably work for any dll that is automatically updating when opening visual studio or hitting the compile button. By removing the "Auto Update" version of type BIN for these two reference dlls, it essentially leaves theme alone when building the project.
I'll have to test these with regard to the Telerik Control Panel to see how and when it updates the references section.
I don't see the properties that you refer to in my copy of VS2013 (perhaps we use different types of projects) but I had posed this question to the folks at Telerik before.
What I was trying to do was to have a network folder store very tightly controlled copies of the Telerik libraries as my application was being tested against those versions and I didn't want anything changing.
However I also wanted to keep up to date for other projects and to evaluate bug fixes. When I received updates to those libraries, I would install the updates using the Telerik installer (and leave them there, which is the problem), and then VS2013 would find the files in the GAC and update my project's references to those versions when I re-opened a project.
The response from the Telerik support staff indicated that a likely solution would be to use the network drive as I was doing, and just remove all versions from my PC after downloading and safely storing the updates away somewhere. This seems to be similar to other solutions I've seen on SO as well.

Visual Studio Toolbox Not Including User Controls from Another Project from Same Solution

I have looked everywhere and cannot find a solution. My problem has the following elements:
I have a Visual Studio Solution (Visual Studio 2013) with several projects.
One project ("Control Project") has several user controls I built.
Other projects ("Other Control Projects") contain various open source controls.
Another project (the "Problem Project") references the Control Project and the Other Control Projects.
The Visual Designer toolbox shows the Other Control Project controls perfectly in my Problem Project.
The Visual Designer fails to show the Control Project controls in my Problem Project.
I have tried:
1. Making sure the option to auto-populate the toolbox is checked.
2. Rebuilding the solution
3. Resetting the toolbox
4. Ensuring the access modifiers for the controls are Public.
If I "Choose Items", I can add the Control Project controls to the Problem Project by selected the .exe but this seems like a hack and also has caused other problems that are difficult to define.
Anybody have any clues on what may be wrong with either my Problem Project or my Control Project?
That answer might be a bit late but I recently had the same Problem.
For me it was a Problem with missing DLLs.
I have a nearly simular Soloution like you.
A Library providing selfmade UserControls
Another project ("Problem Project") that references the Control Library
The problem occurred when I recently switched from VS2008 to VS2013 and from .NET Framework 3.5 to .NET Framework 4.5. The cause of the Problem for me seems to be with Crystal Reports references. In my Library project I have a Class that inherits from CrystalDecisions.CrystalReports.Engine.ReportClass. This Class I provide as a control in the Toolbox. When I open the Library Project itself (not as a Subproject) and open a Form to load the Toolbox I got the following Error: Failed to create ToolboxItem of type: CrystalDecisions.VSDesigner.ReportToolboxItem, CrystalDecsions.VSDesigner.
After I knew this I found out, that I have to copy some Librarys, in my case
CrystalDecisions.CrystalReports.Engine.dll
CrystalDecisions.Shared.dll
CrystalDecisions.VSDesigner
to C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE (found it here:Can't add project controls to the Visual Studio Toolbox)
To me it seems like VS Toolbox starts to create the Controls and gets an Error at one of them and stops to fill the Toolbox. In my case the problem might be, that I reference old CR Librarys (v12.x) which work with CLR 2.0 and .NET Framework 2.0 - 3.5 and I compile my project with .NET Framework 4.5 which works with CLR 4.0. It looks like the old Librarys are not supported in .NET 4.x. If I use this Workaround the Toolbox works fine for me.
Greetings
btw. sorry for the patchy english ;-)

asp.net application with multiple projects cannot load type of page code

I have a ASP.Net application that uses multiple web projects. It is set up to conform to the way Microsoft says to do this. To be clear there is one solution with multiple web project where one serves as the base project and the others are children.
I have it all working pretty well. Recently I took out a VB project and replaced it with a C# project. Now in that project whenever I try to load a page under the base project it says that it cannot load the type like what is discussed here: http://support.microsoft.com/kb/306155
When you just browse the web form from the project though (not run the solution for debugging) you do not get this error.
Any ideas?
It sounds like you may have just broken a reference in the main project. Whenever you remove a project that is referenced by project, it automatically removes it as a dependency wherever it's used.

Do controls need to be defined in a web app or will .NET do it for you

I always thought that when you dropped a control onto an .aspx page that a declaration of that control ended up being generated for you (either in a designer file, or within your code behind). All of the apps I have worked on have worked this way.
A coworker of mine was installing resharper and it was showing that all her code behind pages would not build. Turned out that resharper could not find a definition for any control that she has dropped onto her markup. She has no designer files, and no declarations in markup. Do they get automatically built when putting together the partial classes? Is there an option at that page/project level to instruct .NET to do this for you? Is this a difference between web app and web site?
This is a a .NET 3.5 site, C#, and it is running in a production environment.
Thanks in advance
You are correct in the difference is that she's running a Web Site project as opposed to a Web Application project. In a website there are no designer files. So to answer each of your questions...
Do they get automatically built when putting together the partial classes?
Yes, when the .aspx gets compiled the controls are created as if they were there...this happens in the background in VS so you get intellisense.
Is there an option at that page/project level to instruct .NET to do this for you?
Kinda, use a Web Application project for this :)
Is this a difference between web app and web site?
Yes, one of the main differences :) Web Application projects have a Page.aspx.designer.cs that house the control declarations.

Categories

Resources