asp.net application moved - namespace not found - asp.net

I had an installation of Umbraco in a subdirectory of wwwroot.
Everything worked well.
Now I moved all the files and folders of the Umbraco installation from the subdirectory to the wwwroot.
When I try to load the backend I get an error:
CS0246: The type or namespace name
'UmbracoMembership' could not be found
(are you missing a using directive or
an assembly reference?)
Now UmbracoMembership is a class of a custom usercontrol, which resides in the Membership.dll file which is in the bin folder.
Before the move everything worked. I'm guessing this has something to do with where asp.net is looking for the assemblies (and not an Umbraco specific issue), but I have no idea where and how to fix this.
Thank you!
-Elad

Check if you need to append namespace definition in your web.config. These will be applied to all pages.
<configuration>
<system.web>
<pages>
<namespaces>
<add namespace="MyNamespace" />
</namespaces>
</pages>
</system.web>
</configuration>

Related

Getting errors from web.config of parent application in my sub application

I have my main website's application on my server at C:\inetpub\wwwroot, which I can view at http://www.mysite.com
I've created another separate MVC web application, named Supapp, at C:\inetpub\Supapp. I'd like to set it up so that if I visit http://www.mysite.com/Subdir, it will run my Subdir app.
So I went into IIS, expanded my existing website, and added a new Application, pointing the root folder to C:\inetpub\Supapp\.
When I go to view http://www.mysite.com/Subdir, I get a compilation error:
Compiler Error Message: CS0246: The type or namespace name 'MySite' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 98: <add namespace="System.Web.Mvc.Html" />
Line 99: <add namespace="System.Web.Routing" />
Line 100: <add namespace="MySite.HtmlHelpers" />
Line 101: </namespaces>
Line 102: </pages>
Source File: c:\inetpub\wwwroot\web.config Line: 100
So for some reason, my sub application is getting an error from trying to load a namespace from the parent application.
Is there a way around this? The Subdir application is in a completely different directory.
config files are hierarchical, your sub web.config inherit things from your root .config. If you want certain parts to be ignred you can add inheritInChildApplications="false" attribute to tags you don't to be inherited.
For your case add inheritInChildApplications="false" to your aplication root location
<location path="." inheritInChildApplications="false">
</location>
You will need to set up your sub application to be a web application in IIS.

Telerik namespace not found in deployed MVC3 application

I have just deployed a new MVC3 application, and after some efforts on my hosting provider's side, MVC3 seems to be running OK, but now I get the following compilation error before anything on the site loads:
CS0246: The type or namespace name 'Telerik' could not be found (are you missing a using directive or an assembly reference?)
This occurs in web.config on the following line:
<add namespace="Telerik.Web.Mvc.UI" />
I know the DLL is present in the bin folder on the host, so I'm a bit lost as to what else could be wrong.
If you are using Razor this line:
<add namespace="Telerik.Web.Mvc.UI" />
must occur in ~/Views/web.config and not in ~/web.config. Could this be your case?
Like this:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Telerik.Web.Mvc.UI" />
</namespaces>
</pages>
</system.web.webPages.razor>
http://www.telerik.com/community/forums/aspnet-mvc/general/issue-with-telerik-mvc3-razor-content-appearing-at-the-top.aspx
Read the reply by Mike Kidder. Sorry for linking another forum, I know that's annoying but I'd rather give credit where due.
Two big takeaways when converting to Razor syntax:
1) Use #( .... ) when outputting html, not #{ .... ;}
- wrap the code for Telerik controls in parentheses, not brackets
- using brackets, you're essentially telling Razor to execute a method. You won't get any output
2) Remove the ".Render()" method for any Telerik controls. Not used in Razor.
You have to set Copy Local to true for the assemblies you have referenced. In your case expand References, select the assembly, press F4 to open the properties and set Copy Local to true. The assembly most probably is installed in the GAC so when you add a reference to it by default Copy Local is false.
it might be in the bin folder but, since you didn't mention this, did you actually add reference to the file in the project? after adding the reference to the dll, it should build correctly

Namespace removed in web.config not removed in a page with master

I have defined this in the web.config of a subdirectory
<namespaces>
<remove namespace="App"/>
<add namespace="Tom"/>
</namespaces>
App is imported in the parent web.config file, Tom and App have classes with the same names.
To avoid errors resulting from ambiguous class names I removed the App namespace from the sub-directory where the Tom namespace is used.
However the namespace App is still imported on content pages that have a master page outside the Tom directory. This causes the aforementioned errors.
Here is my dir structure
-Root Directory
--Default.master
--web.config (App is added in web.config)
--Tom Sub-diretory
---web.config (App is removed in web.config)
---Content page that uses Default.master (Here is the problem)
---Page without master (Works OK)
Any solutions?
Suppose you have the following in the root web.config:
<namespaces>
<add namespace="App" />
<add namespace="Tom" />
</namespaces>
And in your sub web.config:
<namespaces>
<remove namespace="App" />
<add namespace="Tom" />
</namespaces>
There will be no problem to use the class in .aspx pages in the sub-folder even if they derive from a master page in the root folder but you won't be able to use it in the master page. In the root master page you will need to fully qualify the type: <%= App.DuplicateType %> or <%= Tom.DuplicateType %>.
What about explicitly prefix the usages with the namespace? That should always work.

Known Issues about having multiple web.config files and visual studio 2005/2008 SP1

I seem to be having a problem with my visual studio 2005/2008 installation or something because it isn't providing any IntelliSense whatsoever for controls registered on web.config files in folders different from the root, but it isn't showing any errors neither. Is this behavior normal?
I have access only to the folder of my sub-app, so I can't modify the root's web.config file. Well I COULD, but I'm NOT allowed to.
What I'm trying is to register some WebUserControl's on the web.config file for my sub-app folder, so all the pages in my sub-app can use the WebUserControl's without having to register them on every page, but I'm not getting IntelliSense for those controls registered on the web.config file on my sub-app folder, but I do get IntelliSense if I register them on the root's web.config file. IntelliSense for everything else appears to be working fine.
In the web.config file on my sub-app folder I have something like the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="qme" tagName="EmptySearchMessage" src="~/QMinerals/WebUserControls/EmptySearchMessage.ascx"/>
<add tagPrefix="uc1" tagName="uc_general" src="~/uc_general.ascx" />
<add tagPrefix="uc1" tagName="uc_menu" src="~/uc_menu.ascx" />
</controls>
</pages>
</system.web>
</configuration>
am I doing something wrong?
Update
Now I have upgraded to VS2008 SP1 and the issue persist
Did you try removing "~" from the path and using it relative to web.config? (yeah, even if works now)
Do you have Visual Studio 2005 Service Pack 1?

"Invalid token ',' in class, struct, or interface" after checkout

I am having problems compiling an EPiServer Web Application after checking it out of Subversion.
I get this error
Compiler Error Message: CS1519: Invalid token ',' in class, struct, or interface member declaration
Source Error:
Line 116: }
Line 117:
Line 118: public virtual EPiServer.Personalization.SubscriptionInfo, EPiServerSubscription Info {
Line 119: get {
Line 120: return ((EPiServer.Personalization.SubscriptionInfo, EPiServer)this.GetPropertyValue("SubscriptionInfo")));
Source File:
c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\956e6fc5\66c11597\App_Code.9_fan95p.0.cs Line: 118
As you can see from the error, this file is in the "Temporary ASP.NET Files" folder and is part of the build process. This is not my source code.
I have seen this question which suggests that the web config contains type references
specified in the "Namespace.ClassName,
AssemblyName" format.
So I went into my web.config and changed the section
...
<profile ...>
<properties>
...
<add name="SubscriptionInfo"
type="EPiServer.Personalization.SubscriptionInfo, EPiServer"
provider="SqlProfile" />
...
to
...
<profile ...>
<properties>
...
<add name="SubscriptionInfo"
type="EPiServer.Personalization.SubscriptionInfo"
provider="SqlProfile" />
...
This removed the immediate error above but then I got the same error for a different type. So I went through all the types that were in "Namespace.TypeName, AssemblyName" format and removed the ", AssemblyName". This stopped all the CS1519 errors but then I start getting CS0234:
Compiler Error Message: CS0234: The
type or namespace name
'Personalization' does not exist in
the namespace 'EPiServer' (are you
missing an assembly reference?)
Source Error:
Line 116: }
Line 117:
Line 118: public virtual EPiServer.Personalization.SubscriptionInfo
SubscriptionInfo {
Line 119: get {
Line 120: return
((EPiServer.Personalization.SubscriptionInfo)(this.GetPropertyValue("SubscriptionInfo")));
I am using VisualStudio 2008, Episerver 5.2.372.7, VisualSVN 1.7.2 and a Debian box as the Subversion repo running svn version 1.4.2 (r22196).
The application built fine, then I checked it in to the repo. Checked it out to a different location on the same computer and hit F5 and these errors start to appear.
Does anyone have any suggestions.
UPDATE:
Thanks for your replies devio, Zhaph.
I have added the following to my web.config in the <compilation> section:
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="EPiServer, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.BaseLibrary, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Configuration, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Enterprise, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Implementation, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Lucene, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Scheduler, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Web.WebControls, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.WorkflowFoundation, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Wsrp, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.XForms, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
</assemblies>
There was no <assemblies> section previously.
The project has all of those DLLs in its References. All the EPiServer DLLs are in the GAC.
The new (non-working) checkout is on the same machine that the original project was created on.
I now get :
Parser Error Message: Could not load
file or assembly 'EPiServer.Scheduler'
or one of its dependencies. The system
cannot find the file specified.
(C:\Projects\web\ProvidentPPC2\ProvidentPPC\web.config line 301)
Source Error:
Line 299: <add name="InitializationModule" type="EPiServer.Web.InitializationModule" />
Line 300: <!--<add name="BasicAuthentication" type="EPiServer.Security.BasicAuthentication, EPiServer" />-->
Line 301: <add name="Initializer" type="EPiServer.Scheduler.Initializer, EPiServer.Scheduler" />
Line 302: <add name="WorkflowRuntime" type="EPiServer.WorkflowFoundation.WorkflowSystem" />
Line 303: <add name="UrlRewriteModule" type="EPiServer.Web.UrlRewriteModule" />
Source File:
C:\Projects\web\ProvidentPPC2\ProvidentPPC\web.config
Line: 301
As I say EPiServer.Scheduler is in my GAC and added to the project as a reference.
Any more ideas would be greately appreciated.
I encountered this problem as I was restructuring the dll references in a project.
I had moved the external/third part dlls from the bin folder to a library folder outside the web project root.
My problem was that some of the dll references did not have copy local set to true, so they were never copied to the bin folder on build.
It's been a while since I asked this and I keep looking thinking that I need to remember what the issue was and post the answer. I think this is it.
It turned out that there was an issue with application finding the DLLs that EPiServer installed. I'm not sure exactly and I'll update this post once I get chance to try it out on a clean machine, I'm still mid-project so it's not a very good time to be faffing about.
The way I fixed it was to get the DLLs from c:\Program Files\EPiServer\CMS\VERSION\bin and put them in the bin folder for the application.
Once I get chance to do a clean install somewhere I'll see if it is infact the project (which I doubt) or, more likely, the installation on my computer which is broken.
Have you tried referencing the EPiServer assembly correctly?
I assume that it's displaying ok in the project references node in the Solution Explorer, and hasn't got a yellow exclaim overlay on it?
Perhaps you could reference it in the web.config compilation section as well:
<compilation debug="false">
<assemblies>
[...]
<add assembly="Episerver, Version=5.2.372.7"/>
</assemblies>
</compilation>
You may either not need the version number, or you may need to add the version number and culture type - there should be a few other assemblies referenced in there already for reference.
You could also try:
<add assembly="EPiServer" />
and other variations.
Sounds like an Assembly Load issue then:
Check that the EPiServer DLL is accessable in your new location - is it installed to your computers Global Assembly Cache, or is it a local reference to the /bin folder? Is the dll in the bin folder? Is the dll included in source control?
I ran into this several times and done it for me is when I manually copied the EPiServer assemblies to the bin folder. That works for sure but it's not very elegant. Zhaph's solution with the assemblies tag looks much nicer I'll try it next time.
I just had a similar problem this afternoon. The problem was that the EpiServer dlls were not present in the bin directory of the website, so I got bind failures.
The project had been created by one of my colleagues and the relevant EpiServer dlls were added as solution items in a lib folder and referenced from there. However, as he had initially created it from the EpiServer project template, the libraries had automatically been added to the bin folder also. When he updated the references to point to the lib folder, copy local defaulted to false. This still worked on his machine due to the original copies placed in the bin folder by the template. Updating them to CopyLocal = True fixed the issue.
I just had this same problem, again with an EPiServer site. It was because I was referencing the EPiServer DLLs, but they did not have the "copy to local" property set to true on all the references, and so they were not all being placed in the bin directory.
Delete everything from BIN Folder and copy all the files from [ASSEMBLIES] in to BIN Folder fixed the problem for me.
Khizer Jalal
I guess the original error message meant you had a malformed C# expression in
return ((EPiServer.Personalization.SubscriptionInfo, EPiServer)...
nothing to do with the config file.
Probably you typed "," instead of "." ? (As the compiler reads this, you provide 2 types in the cast)
Revert web.config to its original version and fix the typo, that should work.
update after Greg's comment:
I didn't realize the config section you posted were part of the EPIServer configuration. You were right then to remove the assembly names.
However I guess you need to reference the EPiServer from the web app (Add Reference...). I think I noticed this in my projects too: If you checkout an ASP.Net app to a new location, you need to add all references again.

Resources