.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Linq to XSD: How to use Linq to XSD functionality in general application.
• .NET Framework Setup
• .NET Base Class Library
• Windows Presentation Foundation (WPF)
• Regular Expressions
• MSBuild
• JScript for the .NET Framework
• Common Language Runtime
• Building Development and Diagnostic Tools for .Net
• ASMX Web Services and XML Serialization
• 64-Bit .NET Framework Development
• .NET Remoting and Runtime Serialization
• .NET Framework Networking and Communication
• Managed Extensibility Framework
• Network Class Library (System.Net)
• Windows Communication Foundation
• Microsoft Codename 'Oslo'
• Chart Controls for .NET Framework
• Claims based access platform (CBA), code-named Geneva
• .NET StockTrader Sample Application

Linq to XSD: How to use Linq to XSD functionality in general application.

Hi All,

i have created sample project window forms application in C#, without selecting the LiNQ to XSD. And now i want to add the LINQ to XSD functionality to my exisiting application. So i included reference to the "Microsoft.Xml.Schema.Linq.DLL" dll in the current project. After i have added my xsd file to the project. Now when i try to change the BuildAction of the XSD to "LinqToXsdSchema", it is not happening. I mean the option is not coming in propery view of the xsd file. Please let me know what are the changes i need to do.

Please it is very urgent for me. Please reply me back asap.
chandu928
Hi,

in order to use LINQ to XSD make sure you are using the latest version i.e. do not use any of the Preview Alphaversions.LINQ to XSD was recently released on CodePlex [1].

You need to follow a few steps to make LINQ to XSD work for your project.

1. Start the 'Visual Studio 2008 Command Prompt' from the start menu.

2. If not done so far, create a directory that will contain your LinqToXsd binaries (e.g. c:\LinqToXsdBin)

3. Type 'SET LINQTOXSDBINDIR=C:\LINQTOXSDBIN' (replace with the path you have chosen from 2.)

4. Start Visual Studio from within the command prompt (type 'devenv.exe'). That's the reason we started the 'Visual Studio 2008 Command Propmt'.

5. Open the XObjects.sln solution file from the LinqToXsd project and compile. The binaries will be dropped to the directory you specified before
using the environmental variable LINQTOXSDBINDIR.

6. Open your own project/solution. It is very important that you open your project/solution from the Visual Studio instance that was started from the command prompt where the LINQTOXSDBINDIR variable was defined. That way Visual Studio will be able to pick up the build tasks. If you have already compiled LinqToXsd, you can skip step 5, but not the steps before.

7. Before you can use the build tasks, you have to prepare your project file. Right click the project in Solution Explorer at select 'Unload Project'.

8. Right click the project (unloaded) again and select 'Edit [YourProjectFileName].csproj'. The project file will be opened in the Visual Studio XML text editor.

9. Navigate to the end of the file. Now add the following lines into the project file below the last 'PropertyGroup':


<PropertyGroup>
   <LinqToXsdBinDir Condition="'$(LinqToXsdBinDir)' == ''">$(SolutionDir)</LinqToXsdBinDir>
</PropertyGroup>


10. Now navigate to the very end of the file below the very last and insert the following lines after the very last 'Import'. Enter the following line. It is very important that this line is located after all other import statements.


<Import Project="$(LinqToXsdBinDir)\LinqToXsd.targets" />

11. Right click your project and select 'Reload Project.

Now you should be able to select LinqToXsdSchema from as build action for your XSD file.

I assume the option might not be shown in your project as Visual Studio was not started in the proper context with the LINQTOXSDBINDIR environmental variable defined (e.g. started from a shortcut).

The previously described steps should work for both, Visual Studio 2008 and Visual Studio 2010. In order to you Visual Studio 2010 you have to start the 'Visual Studio 2010 Command Propmpt' instead.

Andreas
Andreas Heil
Hi,

in order to use LINQ to XSD make sure you are using the latest version i.e. do not use any of the Preview Alphaversions.LINQ to XSD was recently released on CodePlex [1].

You need to follow a few steps to make LINQ to XSD work for your project.

1. Start the 'Visual Studio 2008 Command Prompt' from the start menu.

2. If not done so far, create a directory that will contain your LinqToXsd binaries (e.g. c:\LinqToXsdBin)

3. Type 'SET LINQTOXSDBINDIR=C:\LINQTOXSDBIN' (replace with the path you have chosen from 2.)

4. Start Visual Studio from within the command prompt (type 'devenv.exe'). That's the reason we started the 'Visual Studio 2008 Command Propmt'.

5. Open the XObjects.sln solution file from the LinqToXsd project and compile. The binaries will be dropped to the directory you specified before
using the environmental variable LINQTOXSDBINDIR.

6. Open your own project/solution. It is very important that you open your project/solution from the Visual Studio instance that was started from the command prompt where the LINQTOXSDBINDIR variable was defined. That way Visual Studio will be able to pick up the build tasks. If you have already compiled LinqToXsd, you can skip step 5, but not the steps before.

7. Before you can use the build tasks, you have to prepare your project file. Right click the project in Solution Explorer at select 'Unload Project'.

8. Right click the project (unloaded) again and select 'Edit [YourProjectFileName].csproj'. The project file will be opened in the Visual Studio XML text editor.

9. Navigate to the end of the file. Now add the following lines into the project file below the last 'PropertyGroup':


<PropertyGroup>
   <LinqToXsdBinDir Condition="'$(LinqToXsdBinDir)' == ''">$(SolutionDir)</LinqToXsdBinDir>
</PropertyGroup>


10. Now navigate to the very end of the file below the very last and insert the following lines after the very last 'Import'. Enter the following line. It is very important that this line is located after all other import statements.


<Import Project="$(LinqToXsdBinDir)\LinqToXsd.targets" />

11. Right click your project and select 'Reload Project.

Now you should be able to select LinqToXsdSchema from as build action for your XSD file.

I assume the option might not be shown in your project as Visual Studio was not started in the proper context with the LINQTOXSDBINDIR environmental variable defined (e.g. started from a shortcut).

The previously described steps should work for both, Visual Studio 2008 and Visual Studio 2010. In order to you Visual Studio 2010 you have to start the 'Visual Studio 2010 Command Propmpt' instead.

Andreas
Andreas Heil
thanks for you reply.

But solution for this i have already implemented by copying from the existing linqtoxsd project (i.e. .csproj file). and it is working fine.

ofcourse, the change of content is same.

Thanks again for reply.


chandu928

You can use google to search for other answers

 

More Threads

• system.file.io library for vb.net 2005
• Regular Expression for character combinations or strings that should NOT match
• Problem in reading Registry from Windows service
• Field Attribute & Code Execution
• Can .NET do this? (Mouse position utility)
• Fix No Of decimal Places in a given number
• Length of 2D array
• How to - Dynamic object creation from configuration file?
• MMC Snap-Ins - handling unhandled exceptions using UnhandledException Event
• Zeros at the beginning of source code