C# 使用制造商&x27;不调用非托管代码,而是按自己的方式调用

C# 使用制造商&x27;不调用非托管代码,而是按自己的方式调用,c#,visual-studio-2010,video,C#,Visual Studio 2010,Video,这是原始代码。 我正在努力完成这件事 using System; using System.Drawing; using System.Runtime.ExceptionServices; using System.Runtime.InteropServices; namespace FlyCapture2Managed { public class ManagedImage : IDisposable { public ManagedImage(); public Manage

这是原始代码。 我正在努力完成这件事

using System;
using System.Drawing;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
namespace FlyCapture2Managed
{
public class ManagedImage : IDisposable
{
    public ManagedImage();
    public ManagedImage(ManagedImage image);
    public ManagedImage(byte* pData, uint dataSize);
    public ManagedImage(uint rows, uint cols, PixelFormat format);
    public ManagedImage(uint rows, uint cols, PixelFormat format, BayerTileFormat bayerFormat);
    public ManagedImage(uint rows, uint cols, uint stride, byte* pData, uint dataSize, PixelFormat format);
    public ManagedImage(uint rows, uint cols, uint stride, byte* pData, uint dataSize, PixelFormat format, BayerTileFormat bayerFormat);
    public ManagedImage(uint rows, uint cols, uint stride, byte* pData, uint dataSize, uint receivedActualSize, PixelFormat format);
    public ManagedImage(uint rows, uint cols, uint stride, byte* pData, uint dataSize, uint receivedActualSize, PixelFormat format, BayerTileFormat
  }
我不断地从错误中得到错误

 using System;
 using System.Drawing;
 using System.Runtime.ExceptionServices;
 using System.Runtime.InteropServices;
 namespace FlyCapture2Managed2
 {
  public struct ManagedImage2 : IDisposable
  {
public ManagedImage2();
public ManagedImage2(ManagedImage image);
public ManagedImage2(byte* pData, uint dataSize);
public ManagedImage2(uint rows, uint cols, PixelFormat format);
public ManagedImage2(uint rows, uint cols, PixelFormat format, BayerTileFormat bayerFormat);
public ManagedImage2(uint rows, uint cols, uint stride, byte* pData, uint dataSize, PixelFormat format);
public ManagedImage2(uint rows, uint cols, uint stride, byte* pData, uint dataSize, PixelFormat format, BayerTileFormat bayerFormat);
public ManagedImage2(uint rows, uint cols, uint stride, byte* pData, uint dataSize, uint receivedActualSize, PixelFormat format);
public ManagedImage2(uint rows, uint cols, uint stride, byte* pData, uint dataSize, uint receivedActualSize, PixelFormat format, BayerTileFormat
  }
  public class managed
    {
    [DllImport(@"S:\FlyCapture2SimpleGUI_CSharp\bin\x64\Debug\FlyCapture2Managedd_v100.dll",  CallingConvention = CallingConvention.Cdecl)]

    static extern void managed();  
}
但是我不想使用引用,因为我更喜欢在工作中引用这段代码


关于

像素格式
枚举是
System.Drawing.Imaging
命名空间的一部分,因此您应该在文件顶部添加以下using指令:

The type or namespace name 'PixelFormat' could not be found (are you missing a 
using directive or an assembly reference?). The Pixelformat in this case is part of the name space "flycapture" and not System.Drawing.imaging namepspace

本例中的Pixelformat是命名空间“flycapture”的一部分,而不是System.Drawing.imaging namepspace。@User146296:那么您应该添加对包含“flycapture”命名空间的库的引用,并使用flycapture添加
在你的文件顶部。我有一件事是,当我这样做时,程序的其他部分将使用flycapture作为参考,我不想这样做happen@user1462296字体你为什么不想这样呢?我想有很大的灵活性。从我所注意到的情况来看,如果不单独使用它,它可能不起作用
using System.Drawing.Imaging;