C# DLL regsvr32 注册找不到入口,这是为什么?

fzcheng 2012-05-18 10:10:02
是不是什么地方要设置,请帮忙弄下好吗?

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)
{。。。}
...全文
496 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
Teng_s2000 2012-05-18
  • 打赏
  • 举报
回复
原来C#的dll还可以这样注册呢?学了一招
花痴 2012-05-18
  • 打赏
  • 举报
回复
C#写的dll其实是被称作类库(Class Library)的东西的。跟Windows组件不太一样的说……
WAN 2012-05-18
  • 打赏
  • 举报
回复
使用regasm将其向COM注册,JS下可调用该COM
http://msdn.microsoft.com/zh-cn/library/h627s4zy(v=vs.100).aspx
fzcheng 2012-05-18
  • 打赏
  • 举报
回复
我现在就想在JS下面去引用
fzcheng 2012-05-18
  • 打赏
  • 举报
回复
在BS JS下面可以调用不?
hard9999 2012-05-18
  • 打赏
  • 举报
回复
C#的dll,放在当前程序目录添加引用就可以了,或者用gacutil放到全局共享缓存就可以引用了。不需要注册,
fzcheng 2012-05-18
  • 打赏
  • 举报
回复
gacutil.exe这个工具没有哦!
qldsrx 2012-05-18
  • 打赏
  • 举报
回复
C#写的dll是不需要注册的,即使注册的GAC,也不是用那个工具注册,而是用gacutil.exe,这个在.NET的SDK包里面能找到,装过Visual Studio的也可以通过它的命令行直接使用。
注册到GAC后,dll在任何地方都可以使用,而不需要跟着项目复制了。
yuanchunyan 2012-05-18
  • 打赏
  • 举报
回复
呃,最近也在研究这块,貌似托管代码和上面那中注册可以,但是用regsvr32 注册的话都是一些指定的dll,托管的直接在类库中引用就可以
bdmh 2012-05-18
  • 打赏
  • 举报
回复
托管dll不能注册,非托管的才可能行
帮帮你我她 2012-05-18
  • 打赏
  • 举报
回复
VS 的C# 的DLL 是指令集啊,你只需装.NET 包啦, 不要那个注册的,你构建的环境支持不够。。
liqing720 2012-05-18
  • 打赏
  • 举报
回复
你所附带的DLL没有拷贝全吧!你调用的DLL可能有绑定其他的dll文件呢。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧