问题
I'm learning NHibernate and I added <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
to App.config
. Visual Studio reported a message:
Could not find schema information for the element 'urn:nhibernate-configuration-2.2:hibernate-configuration'.
I know this is not a problem, but if VS knew the schema, IntelliSense would work. How can I add the schema?
回答1:
Just include the XSD files in any of your projects or as Solution Items.
回答2:
Copy the two .xsd
from the folder Required_Bins
from the NHibernate download to C:\Program Files\Microsoft Visual Studio 10.0\Xml\Schemas. If you use other version of VS than 2008 (or if you have VS installed elsewhere), change the path accordingly.
回答3:
For those using nuget, and multiple versions of nHibernate, Source control, et al...
Open up the hbm XML file in your project.
Select the XML menu item and select
Schemas
in the drop down (or press ALT, X, S)Click
Add
Browse to your Solution and open the
packages
folder in the rootFind the nHibernate package folder
Select both the XSD files within the
lib
folder
回答4:
I tried some of the above ideas with VS2012 and NHibernate 3.3.1.4000 and it did not work, but the following tip given by ArnonA worked for me. It should also be SVN safe, if you work on multiple projects with different versions of nHibernate
- Inside VS2012, open up the nHibernate xml file you would like to edit.
- Once in the xml file editor, the XML menu should be visible in the main VS menu.
- Click on XML->Schemas menu, this should open the "XML Schemas" dialog.
- Add the "nhibernate-configuration.xsd" and "nhibernate-mapping.xsd" files and click ok.
- Done :)
回答5:
Just copy the nhibernate.xxx.xsd
files into your
%Program Files%\Microsoft Visual Studio %version%\xml\Schemas
folder.
回答6:
You should add xsd files to the solution. This would prevent issues of missing files if your team needs to download the project from a code repository.
来源:https://stackoverflow.com/questions/3565156/how-to-add-nhibernate-xml-schema-to-visual-studio