Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

LicenseException with assembly compiled with NAnt

Hi all,

I use Measurement Studio 7.1 Enterprise Edition for Windows 2000/XP .NET for an application that was developed in C# a few years ago with Visual Studio 2003. The Measurement Studio Tools are installed for VS 2003. The application runs on Windows XP SP2 and must now be modified. Visual Studio 2005 shall be used for that and it shall additionally be possible to compile the application with NAnt.

The Visual Studio 2005 Licensing Patch was installed for that and if the program is compiled with Visual Studio 2005 and is started, no license exception occurs. But if it is compiled with NAnt and started then the license exception occurs.

All source code files and all DLLs are checked in in a version control system (Subversion) and only refered from there. According to the description of the Visual Studio 2005 Licensing Patch the NationalInstruments.Commmon.dll is updated by the License patch from version 7.x to version 8.0.11.141. This is done manually in the repository. But it doesn't help, the license exception still occurs when the application is compiled with NAnt.

I use the NAnt task <license> to create a license file from the existing licx file and to integrate it in the assembly. This seems to work because when I compare the assemblies compiled by VS 2005 and by Nant with .NET Reflector both assemblies have the license integrated with exactly the same size. Also the content is the same (content of licenses.licx in readable text and probably the generated license as hex codes).  

Also the other content is the same in both assemblies according to Reflector.That is to be due because the same cs and resource files are compiled and the application runs the same way except the license exception.

Nevertheless the size of the assembly compiled by Nant is 28KB smaller than the one compiled by VS 2005.
Therefore somehow there's still a difference regarding the licenses. Maybe there's some kind of link to NationalInstruments files.

My question is now what exactly is done during the installation of the Visual Studio 2005 Licensing Patch? Which files are changed/installed? Is really only the "NationalInstruments.Common.dll updated from version 7.1.x to version 8.0.x." as the information about the patch describes? Is there any "special integration" or whatever of the patch into VS 2005 which is not valid for Nant?
Has anybody any experience how to integrate the NationalInstruments license into an assembly compiled with Nant? Are there any links or whatever to NationalInstrument files that are automatically integrated into the assembly when it is compiled by VS ?

Thank you very much for your help,
Rolf-Harm

0 Kudos
Message 1 of 3
(3,515 Views)

Hi Rolf-Harm,

The Visual Studio 2005 patch for Measurement Studio 7.1 simply updates our Common assembly with bug fixes that we found.  Since you are using Visual Studio 2005, I would strongly encourage you to upgrade to the official versions of Measurement Studio that support Visual Studio 2005 which is 8.0.1 and later. This may not be possible, but I would highly recommend it.

Now onto the NAnt situation... 

At some point we were not able get NAnt's <solution> task to compile our assemblies correctly.  Because of the issues we ran into (which was quite a while ago), we decided to move away from someone other than Microsoft keeping the project information and compiling the assemblies.  We now use NAnt to automate the Visual Studio command line.  This also gains us one thing, in that all the information that the developer keeps in the Visual Studio project is certain to be used when compiling that assembly, so the information doesn't need to also be kept in some NAnt build script.  If I remember right, you had to provide a lot of information to NAnt to have it build an assembly.  All of that information is kept in the project files and the developer can edit them in a more intuitive manner than using the NAnt XML script.

As far as licensing goes, we haven't used the <license> task with NAnt at all.  Honestly, just to get our licensing working in Visual Studio required us to modify and customize certain components and behaviors.  So my guess would be that NAnt isn't accounting for our customization.

So my suggestion to you is to follow what we have done with regards to NAnt to avoid any of those issues we ran into.  I would be happy to give the source to this task if this would help you out.

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 2 of 3
(3,489 Views)
Hello Jonathan,
thanks for the offer but after some more time and digging through the NAnt code I got a solution.
Vamshi Bhoopalam got the same problem with including a license and gave very valuable hints (thanks to him!) on
http://www.dotnetspider.com/kb/Article1561.aspx

In case some other people have the same requirements here comes a shortened build file as example.
In this build file the license is included in a dll B which is later on referenced by a xy.exe that also includes the license.

Best regards,
Rolf-Harm

<?xml version="1.0"?>
<project name="xy_System" default="build" basedir=".">
    <target name="B" depends="A" description="Creates the B dll" verbose="true">
        <mkdir dir="${b.dll.bin.dir}" />
        <license input=".\B\licenses.licx" target="B.dll" output="B.dll.license" verbose="true">
        <assemblies>
            <!-- Specify the path to dlls being referenced when compiling this assembly -->
            <include name="${A.dll.bin.dir}/A.dll" />
            <include name="${DLL.basedir}/NationalInstruments.Common.dll" />
            <include name="${DLL.basedir}/NationalInstruments.UI.dll" />
            <include name="${DLL.basedir}/NationalInstruments.UI.WindowsForms.dll" />
            <include name="${MicrosoftNet.basedir}/System.dll" />
            <include name="${MicrosoftNet.basedir}/System.Drawing.dll" />
            ...            
          </assemblies>
        </license>
        <csc target="library" output="${B.dll.bin.dir}/B.dll" debug="${debug}">
            <references>
                ...
                <include name="${DLL.basedir}/NationalInstruments.Common.dll" />
                <include name="${DLL.basedir}/NationalInstruments.UI.dll" />
                <include name="${DLL.basedir}/NationalInstruments.UI.WindowsForms.dll" />
                <include name="${A.dll.bin.dir}/A.dll" />
            </references>
            <sources>
                ...
            </sources>
            <resources>
                ...
            </resources>
             <arg value="/resource:B.dll.license,B.dll.licenses"  />
        </csc>
    </target>

    <!-- Build all and copy all files to output directory   -->
    <target name="xy_exe" depends="B" verbose="true" description="Creates the xy.exe">
        <license input=".\xy\licenses.licx" target="xy.exe" output="xy.exe.license" verbose="true">
        <assemblies>
            <!-- Specify the path to dlls being referenced when compiling this assembly -->
            <include name="${A.dll.bin.dir}/A.dll" />
            <include name="${DLL.basedir}/NationalInstruments.Common.dll" />
            <include name="${DLL.basedir}/NationalInstruments.UI.dll" />
            <include name="${DLL.basedir}/NationalInstruments.UI.WindowsForms.dll" />
            ...
            <include name="${MicrosoftNet.basedir}/System.dll" />
            <include name="${MicrosoftNet.basedir}/System.Drawing.dll" />
            <include name="${MicrosoftNet.basedir}/System.Windows.Forms.dll" />
            <include name="${B.dll.bin.dir}/B.dll" />
            ...
          </assemblies>
        </license>

        <mkdir dir="${xy.exe.bin.dir}" failonerror="false" />
        <csc target="exe" output="${xy.exe.bin.dir}/xy.exe" debug="${debug}">
            <references>
                <include name="${DLL.basedir}/NationalInstruments.Common.dll" />
                <include name="${DLL.basedir}/NationalInstruments.UI.WindowsForms.dll" />
                <include name="${DLL.basedir}/NationalInstruments.UI.dll" />
                <include name="${A.dll.bin.dir}/A.dll" />
                <include name="${B.dll.bin.dir}/B.dll" />
                ...
            </references>
            <sources>
                ...
            </sources>
            <resources>
                ...
            </resources>
             <arg value="/resource:xy.exe.license,xy.exe.licenses"  />
        </csc>

        <!-- Copy the generated files -->
        ...
    </target>
    
</project>

0 Kudos
Message 3 of 3
(3,415 Views)