I have recently run on this problem. I have tried to add namespace to Views/web.config or on top of the view, but still occur on the problem, where View can't find the contents of namespace.
Problem
Ofcorse it is not a big problem, but it is annoying to always write the full namespace.
Maybe you should try write another using that contains your Resources path?
Related
I have encountered an error that prevents me from uploading the webpage to the server. I managed to let it work without any errors when I am running visual studio.
Here's the error
However, when I removed Inherits="testconnect.index" , it can work but it cannot connect index.aspx.cs to index.aspx.
Like for example:
With lbl_test.Text inside the index.aspx
Does anyone knows how to fix the error?
You're trying to inherit from testconnect.index, but your class is named index1. Can you change the class name to index? Or, conversely, set the Inherits directive to inherit from testconnect.index1?
You have to specify the exact name of the class in order to reference it. "Close enough" isn't close enough.
(Note also that Visual Studio is trying to tell you in your index1 class that lbl_test doesn't exist. Supposedly perhaps the designer partial class is index? If that's the case, you'll probably want to just rename this partial class to index as well.)
Okay I have got it working by changing CodeBehind="index.master.cs" to CodeFile="index.master.cs". I learned that you will have to compile the file first if you want to use CodeBehind. Other than that, it is recommended not to name the aspx page exactly similar to masterpage.
I'm trying to integrate reporting services in an C# application, but when I'm trying to compile it I'm getting a bunch of 'already contains' errors, just like those two:
error CS0101: The namespace 'Microsoft.SqlServer.ReportingServices2005' already contains a definition for 'ListSecureMethodsCompletedEventHandler'
error CS0101: The namespace 'Microsoft.SqlServer.ReportingServices2005' already contains a definition for 'GetRenderResourceCompletedEventHandler'
They all come from ReportingServices2005.cs file, which was generated using wsdl and which I included in the project. What am I doing wrong here?
I probably should also mention that I'm using ReportingService2010.cs and ReportExecution.cs.
Well, that was easy enough. It was my first time using ReportingServices in C# and I misread the documentation. I thought both ReportingService2005 and 2010 are needed. After excluding ReportingService2005 and changing a few things everything worked.
When I generate documentation using Doxygen I get several empty packages representing system namespaces like 'Linq' and so on. The question is how to get rid of them?
I had the same problem and found one solution. Putting the using ... lines between \cond and \endcond tags hides them in the helpfile output.
I'm not very glad about that, changing something in the doxy file would be easier. Maybe there's another better solution?
The problem is new with the new doxygen version v1.8.1.1
I've removed them by adding this in the Doxyfile
EXCLUDE_SYMBOLS = System
I am new to MVC and I have been following Steven Andersons Pro ASP.Net Mvc 2 framework book but have encountered the following issue.
The following line of code that sits in my site.Master file throws the following error:
<% Html.RenderAction("Menu", "Nav"); %>
{"Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'."}
The problem seems to be within my Partial View that is trying to render the result of the above code.
The actual error that is out put in the browser is as follows:
Could not load type
System.Web.Mvc.ViewUserControl<IEnumerable<WebUI.Models.NavLink>>.
my partial view consists of the following:
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<WebUI.Models.NavLink>>" %>
<%foreach (var link in Model) { %>
<%: Html.RouteLink(link.Text, link.RouteValues }%>
There also seems to be no IntelliSense available for for the Model.
I know it has something to do with the Inheritance but I have checked the namespace and this appears to be correct.
Any help on this would be much appreciated.
Thanks in advance
I'm working through Sanderson's book and had the same problem. The solution is that the file is named NavLink.cs while the menu inherits from NavLinks. Correct the link or rename the file and everything works.
Interesting problem that begs one question: How did you determine from the error message that this was a namespace issue?
Earl B.
I've gotten Anderson's examples working from the first edition of that book. One thing I noticed is that my NavLink is defined in Controllers/NavController.cs and has a namespace of WebUI.Controllers as opposed to WebUI.Models (thus the type is IEnumerable<WebUI.Controllers.NavLink>. The error you are reporting certainly sounds like a namespace issue...
EDIT: One thing I found that helped me troubleshoot those examples was to download his source code and use a file comparison tool to compare his version to mine when I ran into a problem that I just couldn't figure out.
I have also found the the original idea of putting the classes into one file NavController.cs also creates this error.
Separate the classes into 3 files
NavController.cs
NavLink.cs
CategoryLink.cs
All with the same Namespace
namespace WebUI.Controllers
and it should solve the issue
I keep coming accross code samples online for ASP.net c#, however they never seem to list which namespaces they include, for example:
using System.Data.SqlClient;
etc etc
Am I missing something obvious or should I be expected to know exactly what namespaces each code example requires?
When I'm in that situation, typically I search for the class on MSDN. The documentation will tell you which namespaces contain the class.
If they don't include them, you can follow this list in order:
Find that they are in one of the namespaces listed in the "blank code file" template , or
In Visual Studio You can click the missing type and press shift+F10 or Ctrl+. To get the option to automatically add the using statement (if the assembly is referenced)
With Resharper, Select the type and hit alt+enter for Resharper to find the namespace for you, and add it to the usings (possibly even reference the assembly as well)
Go to MSDN and search the name.
Go to Google and search the name (honestly, I normally do this before hitting MSDN anyway)
Compain to the article author
If code samples use the assemblies that a project references by default, then you can hover on the class name and click shift+F10 which will add the using statement automatically. If the class is not in any of the referenced assemblies then you are out of luck and need to know in what assembly does the class resides.
A quick google search can help, and in time you will memorize the namespaces... Of course its best if samples included the namespace and reference info, but mostly they do not.
If you are viewing code in Visual studio, just hover mouse over class or object you want and you will get tool tip about it if assemly of that class is present or you can google for particular class.For example if you want to know more about 'DataTable'class, just google it and you will come to know that its part of Syste.Data namespace.
I'm with the OP on this one. Having to just magically "know" what namespaces are required seems supremely silly.
I spent some time before C# as a Java Developer, and the NetBeans IDE will resolve these for you automatically. Ctrl-Shift-I, and it will insert all the packages (ie, namespaces) you need. If more than one package defines the class you are resolving, a window pops up and lets you choose which one you want.
For as fine a product as VS is, I am incredulous that this feature is not included.