Using Assembly Reference in Global.asax? - visual-studio-2010

I have an app that our offshore developers are trying to update. The code built with no issues a year ago. Now when they checkout the code and try to build it they get a reference error in Global.asax:
Error 1 The type or namespace name 'HartSourceLib' could not be found (are you missing a using directive or an assembly reference?) c:\Users\rs02130\Desktop\bip\BIProductionSupport\Global.asax 24 9 BIProductionSupport
There is a reference in the Project References pointing to the HartSourceLib DLL. The DLL is present in the referenced location and is the same DLL used in the original build. I'm not familiar with the use of external references in Global.asax. We've tried Using, <% Assembly %> and <% Import NameSpace %> and none have resolved the problem. Here's a sample of Global.asax:
Are we missing something in Global.asax? If not what could be causing the reference issue?
Notes: They're using VS2010 and the 3.5 Framework. I converted the Solution to VS2012 and the 4.5 Framework. Neither works.

Make sure the namespace is correct.
then Add
<%# Import Namespace="HartSourceLib" %> at the start of the code below the
<%# Application Language="C#" %>
After that, make sure HartSourceLib exist in web.config file, then mark HartSourceLib file to be copied to output folder on the file properties.
Finally clean your project and build.
I hope that solve your issue.

Related

Deleted files gives CS0246 compiler error in VS2022

I've added 3 default Blazor projects to my solution.
Blazor WebAssembly1
Blazor WebAsssembly2
Blazor Server
The first WebAssembly project is converted to a razor library in order to share code between server and webassembly projects. I also deleted the default pages like FetchData.razor and such.
On compilation I still get compile error on this (the app runs fine though), and I can't seem to resolve them. I've search through the entire solution but can't find any of the files that results in the compile errors.
How to locate the reason for the errors and remove the references? The files are deleted from the project.
Example of compiler error:
CS0246 The type or namepace 'WeatherForecastService' could not be found (are you missing a using directive or an assembly reference?)
The errors in FetchData indicate a problem with the using statements.
Try to check if you have global using, try to remove and declare explicit in the razor page.
Check your CSPROJ and verify the project type, in the RCL the type must be:
<Project Sdk="Microsoft.NET.Sdk.Razor">
In the RCL you haven't a Program/App structure, you have only components and wwwroot elements.
My RCL is composed as follow:
I have also a _Imports.razor with:
#using Microsoft.AspNetCore.Components.Web
...
The issue resolved itself when I restarted Visual Studio.
Sorry for the wild goose chase

System.Data.Linq not loaded in MVC .NET 4.5

I have an ASP.NET MVC4 Web Application project in .NET 4.5 (VS 2012). It is in VB.
It fails loading System.Data.Linq namespace (with all classes and sub-namespaces).
Project has a reference set to System.Data.Linq.dll.
Any ideas where is the problem?
When I try to add Linq2Sql classes, I get such warning:
Namespace or type specified in the Imports 'System.Data.Linq' doesn't contain
any public member or cannot be found. Make sure the namespace or the type is
defined and contains at least one public member. Make sure the imported element
name doesn't use any aliases.
and such errors:
System.Data.Linq.DataContext
But this is just a beginning: if I try to use anything from System.Data.Linq namespace I get an error, for example if I try to use System.Data.Linq.Mapping.DatabaseAttribute, I get such error:
Type 'System.Data.Linq.Mapping.DatabaseAttribute' is not defined.
I had this same problem - and was able to get past it. I'm not entirely sure which of these steps resolved the issue - but this is what I did.
I had originally created the dbml under app_code/gcm
I removed references to System.Data.DataSetExtensions
I deleted the dbml and recreated it outside of the app_code folder
I built the project (no errors/warnings)
I moved the dbml back to the app_code folder and rebuilt (again no errors/warnings)
Hope that helps you get around this.

Combres, compress and combine .js and .css files

I'm trying to add the following to my ASP.Net solution. I installed it using the nuget package "Install-Package Combres.Mvc"
so far I'm not having the best luck with it as I keep getting the following error
'System.Web.Mvc.HtmlHelper' does not contain a definition for 'Combres' and no extension method 'Combres' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
I also followed the advice of this link... and got same error:/
I'd like to make use of some compression & combination tool/framework so I'm hoping someone has any experience with this
I scrapped the whole combress/casette route after a few failed attempts. I read up a bit and saw that Asp.Net MVC 4 supports bundles/combining & compressing natievly. Which worked quite well for me.
Do you have
<%# Import Namespace="Combres" %>
On the top of the page to include the Combres namespace?
For more information (and the Razor syntax) you can also look at: http://combres.codeplex.com/wikipage?title=5-Minute%20Quick%20Start&referringTitle=Home

ASP.NET Mvc convert <%# Import Namespace="Thirpartynamespace" %> to Razor View

I'm trying to convert the mvc 3 aspx view engine to razor view engine below:
<%# Import Namespace="ThirdpartyComp.Web.UI" %>
<% = Html.SomeFunction("Test")%>
to:
#using ThirdpartyComp.Web.UI
#Html.SomeFunction("Test")
When I do #html.SomeFunction(... I get this exeption:
Are you missing a using directive or an assembly reference?
Could anyone please confirm if above is possible, and anything that I'm missing?
Thank you heaps.
The two code snippets are precisely equivalent. The problem lies somewhere else. Ensure that you have referenced the assembly containing this helper to the new project (Add Reference... in the project) and that this assembly is compatible with ASP.NET MVC 3 i.e. it depends on the System.Web.Mvc V3 instead of V2. If this is not the case you might need to recompile it against ASP.NET MVC 3 (if you have the source code) or ask the author for a version which is compatible with it.

External References not referenced in Razor View

I am working with MVC3 with razor view.
I am trying to use a model from different project than the mvc3 project,
for same its report compilation error as
CS0246: The type or namespace name 'MyNameSpace' could not be found (are you missing a using directive or an assembly reference?)
as answered in some other posts, I tried to add #using directive or editing web.config in Views folder, but it is still not working.
Could somebody please suggest.
I was missing a assembly to my project. Seems adding the reference wasn't enough.
Correct, adding the reference wouldn't be enough. It needs to be added as an assembly to the project, or the compiler won't be able to find the library.

Resources