I am getting the following error:
"The type or namespace name 'SolrNet' could not be found (are you missing a using directive or an assembly reference?)"
I have created a new console application in VS2010 and added into program.cs the line
"using SolrNet;"
I've added the project reference to SolrNet.dll version 0.4.0.2002.
Some versions of solr require a reference to system.web but I do not want to do this and I believe this version doesn't have that as a requirement. I've used the object browser and added references to Nhibernate, Castle, Niject and all the other objects.
How can I get my console app to recognise the SolrNet dll?
In the project properties, change the Target Framework from .NET Framework 4 Client Profile to simply .NET Framework 4
Related
ASP.NET Core 6.0 web app. I get an error when I try to map controllers in Startup.cs. The assembly referenced (QESI.Accuracy.Contract) is a project reference, and it works fine.
The line above it loads a class from that project with no issues. This particular assembly is also packaged and used in other solutions, so I'm wondering if something is trying to load the Nuget package instead of the project reference and that is what's causing it to fail.
If I change the name of the assembly for the project to suffix a 2 I get an error that the same type exists in two assemblies. So something somewhere is referencing the version 1.1.58, which would be the nuget package. I've cleared all nuget package caches using these instructions.
I have a new instance of Sitecore 9. I'm trying to create my first component, an ascx file with a codebehind file, and I have this line:
var item = Sitecore.Context.Item;
The build is failing with the error "The name 'Sitecore' does not exist in the current context"
please make sure that you have added the reference to "Sitecore.Kernel.dll". i would suggest you to also checkout the nuget packages provided from Sitecore:
Sitecore Nuget Feeds
Depending on your deployment Strategy it would be a good practice to use the nuget. Sitecore has created every nuget package with ".NoReferences" extension for example : "Sitecore.Kernel.NoReferences" which is great for dependency management.
If you are using MVC you will need also "Sitecore.Mvc.dll".
In my case, I had a error specification in the output window for this error which turned out to be an hint to solve this error.
The .NET framework version of my visual studio project was targeted at v4.6.1, updating the project's target framework to v4.6.2 fixed my error : "The name 'Sitecore' does not exist in the current context"!
It seems that the Sitecore.kernel.dll (responsible for using term 'Sitecore' for reference in code like controllers) with version 11.1.0.0 was built against the ".NETFramework,Version=v4.6.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6.1" (of my visual studio project).
Here is the error specification (hint!) in my VS output window that I mentioned earlier:
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3274: The primary reference "Sitecore.Kernel, Version=11.1.0.0, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.6.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6.1".
When i converted a VS2008 project to 2010 it shows an error message
The type name 'IComponentConnector' could not be found in the namespace 'System.Windows.Markup'. This type has been forwarded to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Consider adding a reference to that assembly
and it was build when we add a reference System.Xaml. What would be the reason for need to add additional reference?
In .Net 3.5/3,0, IComponentConnector (namespace System.Windows.Markup) was part of WindowsBase.dll and it was moved in System.Xaml in .net 4.0 onwards.
It seems you are upgrading your project framework 3.5 to 4.0
The type was moved to the new assembly in .net 4?
You are changing you project to use .net 4 and it's telling you that you need this type from that assembly in .net 4.
if you target .net 3.5 you'll find you wont need to do this.
As a thumb rule, always add the namespace that is documented. The document says to use the namespace System.Windows.Markup. It worked in VS2008 probably because System.Xaml was internally using the namespace System.Windows.Markup.
Why can't I add a reference to System.Runtime.Serialization when targeting .net 2.0?
Also if I convert a vs2005 project using System.Runtime.Serialization the vs2010 conversion fails with a build error.
I'm using the DataContract class and the compiler says
The type or namespace name 'DataContract' could not be found (are you missing a using directive or an assembly reference?) C:\Users\my\ClassLibrary1\Class1.cs 8 6 ClassLibrary1
The reason for this is that you need to be using .NET 3.5 to use DataContracts, they are items that were introduced with .NET 3.5 therefore you must target that version.
Here is an MSDN article that talks about one aspect of DataContracts and .NET version.
I want to learn to use Fluent NHibernate, and I'm working in VS2010 Beta2, compiling against .NET 4, but I'm experiencing some problems.
Summary
My main problem (at the moment) is that the namespace FluentNHibernate isn't available even though I've imported all the .dll assemblies mentioned in this guide.
This is what I've done:
1. I downloaded the Fluent NHibernate source from here, extracted the .zip and opened the solution in VS. A dialog asked me if I wanted to convert the solution to a VS2010 solution, so I did.
2. I then went into each project's properties and configured all of them to compile for .NET 4, and built the entire solution.
3. I copied all the .dll files from /bin/Debug/ in the FluentNHibernate to a new folder on my local hard drive.
4. In my example project, I referenced FluentNHibernate.dll and NHibernate.dll from the new folder.
This is my problem:
If I right-click on FluentNHibernate in the References list and select "View in Object Browser...", it shows up correctly.
Now, when I try to create a mapping class, I can't import FluentNHibernate. This code:
using FluentNHibernate.Mapping;
namespace FluentNHExample.Mappings
{
}
generates an error on the using statement, saying
The type or namespace 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?).
The FluentNHibernate assembly is still in the list of References of my project, but if I try to browse the assembly in Object Browser again, it can't be found.
What is causing this?
I also had similar problem.
"Error List" window displayed:
The type or namespace name 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?)
But "Output" window was displaying detailed information:
warning MSB3253: The referenced assembly "FluentNHibernate" could not be resolved because it has a dependency on "System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.
In my case; I had created a console application project which was targeting ".Net Framework 4 Client Profile" by default, so changing to ".Net Framework 4" fixed issue for me.
I'm unable to observe this behavior in my build, could it be related to this problem: Weird override problem with Fluent NHibernate and .NET 4
If so you could try http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/ae4013d711d2e4ad as a potential fix.
Isn't there a better way to fix this problem?
I don't want to reference System.Data.OracleClient. So I shouldn't have to target the full .Net framework if I don't even want that reference.
Can't I target the Client Profile of the .Net framework, but add a compiler warning exception somewhere so that it just skips that warning? I know it won't cause a runtime problem because I don't use Oracle.
I get identical problem which says there's also a dependency on System.Web. Same story, this is for a Windows WPF app, so I don't need System.Web. Can't I just target the Client Profile and somehow convince the compiler to keep going?
Thanks,
Hugh
EDIT: I figured this out! I had to compile NHibernate myself though. Opened the 2.1.2 code in Visual Studio and deleted everything that says "Oracle" or "System.Web" and I ended up getting it to build. I do not have to target the full .Net Framework now.
We had this issue and the issue went away if we removed the obj and bin folder from the project which was referencing the NHibernate using project.
So we have 'project1' which uses NHibernate to produce project1.dll.
'project2' references project1.dll.
Problem resolved if we removed the obj/bin folder from project2.
Can't say why, but our solution now compiles fine.
Mike.