Question

<project name="aa" default="createqueue" xmlns="http://nant.sf.net/release/0.85/nant.xsd">
<target name="createqueue">
<echo message="started" />
    <script language="C#" >
            <references>
                <lib>
                    <include name="C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Messaging.dll" />
                </lib>
            </references>
            <imports>
                  <import namespace="System" />
                  <import namespace="System.Messaging" />
            </imports>
            <code>
                <![CDATA[
                public static void ScriptMain(Project project)
                    {
                        string queueName = @".\Public$\TicketMatchingService";
                        if (!MessageQueue.Exists(queueName))
                        {
                            MessageQueue.Create(queueName, true);
                        }
                    }
                ]]>
            </code>
    </script>
    <echo message="ended" />
</target>
</project>

I am getting the following error message

C:\queuetask.build(4,3):
Compilation failed:
c:\Documents and Settings\refundspair1\Local Settings\Temp\pnf11egc.0.cs(17,14) : error CS0234: The type or namespace name 'Messaging' does not exist in the namespace 'System' (are you missing an assembly reference?)
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3603
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using NAnt.Core;
using NAnt.Core.Attributes;
using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Messaging;
using System.Text;
using System.Text.RegularExpressions;



[FunctionSet("script", "script")]
public class nant0aac150cbd424d3c93af8adc13adf050 : NAnt.Core.FunctionSetBase {


    public static void ScriptMain(Project project)
     {
      string queueName = @".\Public$\TicketMatchingService";
      if (!MessageQueue.Exists(queueName))
      {
       MessageQueue.Create(queueName, true);
      }
     }


    public nant0aac150cbd424d3c93af8adc13adf050(NAnt.Core.Project project, NAnt.Core.PropertyDictionary propDict) :
            base(project, propDict) {
    }
}

Total time: 0.3 seconds.
Was it helpful?

Solution

try the following:

<project name="aa" default="createqueue" xmlns="http://nant.sf.net/release/0.85/nant.xsd">
    <target name="createqueue">
        <echo message="started" />
        <script language="C#" >
            <references>
                    <include name="System.Messaging.dll" />
            </references>
            <imports>
                <import namespace="System" />
                <import namespace="System.Messaging" />
            </imports>
            <code>
                <![CDATA[
                    public static void ScriptMain(Project project)
                    {
                    string queueName = @".\Public$\TicketMatchingService";
                    if (!MessageQueue.Exists(queueName))
                    {
                    MessageQueue.Create(queueName, true);
                    }
                    }
                ]]>
            </code>
        </script>
        <echo message="ended" />
    </target>
</project>

I was able to get it to compile successfully using version nant 0.85.248.0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top