是不是什么地方要设置,请帮忙弄下好吗?using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;namespace ZBarcode
{
    public class RawPrintHelper
    {
        // Structure and API declarions:
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public class DOCINFOA
        {
            [MarshalAs(UnmanagedType.LPStr)]
            public string pDocName;
            [MarshalAs(UnmanagedType.LPStr)]
            public string pOutputFile;
            [MarshalAs(UnmanagedType.LPStr)]
            public string pDataType;
        }
        [DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd);        [DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool ClosePrinter(IntPtr hPrinter);        [DllImport("winspool.Drv", EntryPoint = "StartDocPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool StartDocPrinter(IntPtr hPrinter, Int32 level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFOA di);        [DllImport("winspool.Drv", EntryPoint = "EndDocPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool EndDocPrinter(IntPtr hPrinter);        [DllImport("winspool.Drv", EntryPoint = "StartPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool StartPagePrinter(IntPtr hPrinter);        [DllImport("winspool.Drv", EntryPoint = "EndPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool EndPagePrinter(IntPtr hPrinter);        [DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwWritten);        // SendBytesToPrinter()
        // When the function is given a printer name and an unmanaged array
        // of bytes, the function sends those bytes to the print queue.
        // Returns true on success, false on failure.
        public static bool SendBytesToPrinter(string szPrinterName, IntPtr pBytes, Int32 dwCount)
{}

解决方案 »

  1.   

    C#写的dll是不需要注册的,即使注册的GAC,也不是用那个工具注册,而是用gacutil.exe,这个在.NET的SDK包里面能找到,装过Visual Studio的也可以通过它的命令行直接使用。
    注册到GAC后,dll在任何地方都可以使用,而不需要跟着项目复制了。
      

  2.   

    C#的dll,放在当前程序目录添加引用就可以了,或者用gacutil放到全局共享缓存就可以引用了。不需要注册,
      

  3.   

    使用regasm将其向COM注册,JS下可调用该COM
    http://msdn.microsoft.com/zh-cn/library/h627s4zy(v=vs.100).aspx
      

  4.   

    C#写的dll其实是被称作类库(Class Library)的东西的。跟Windows组件不太一样的说……
      

  5.   

    原来C#的dll还可以这样注册呢?学了一招
      

  6.   

    你所附带的DLL没有拷贝全吧!你调用的DLL可能有绑定其他的dll文件呢。
      

  7.   

    VS 的C# 的DLL 是指令集啊,你只需装.NET 包啦, 不要那个注册的,你构建的环境支持不够。。
      

  8.   

    托管dll不能注册,非托管的才可能行
      

  9.   

    呃,最近也在研究这块,貌似托管代码和上面那中注册可以,但是用regsvr32 注册的话都是一些指定的dll,托管的直接在类库中引用就可以