由于vb.net转换问题而引用c#Assembly

由于vb.net转换问题而引用c#Assembly,c#,vb.net,visual-studio-2010,C#,Vb.net,Visual Studio 2010,将代码从c#转换到vb.net后,指针和不安全代码出现问题,由于应用程序的原因,我需要使用它们,因此我阅读了有关创建Assembly并在vb.net应用程序中引用它的内容。到目前为止,我还不知道该怎么办。指针(字节)问题 “识别”一词突出显示以下错误信息:“对非共享成员的引用需要对象引用。” 任何帮助都会很好 非常感谢,, 皮特你需要做一个“Class1”的例子 Dim class1instance As New Class1() Dim glyphValues As Byte(,) = cla

将代码从c#转换到vb.net后,指针和不安全代码出现问题,由于应用程序的原因,我需要使用它们,因此我阅读了有关创建Assembly并在vb.net应用程序中引用它的内容。到目前为止,我还不知道该怎么办。指针(字节)问题

“识别”一词突出显示以下错误信息:“对非共享成员的引用需要对象引用。”

任何帮助都会很好

非常感谢,,
皮特

你需要做一个“Class1”的例子

Dim class1instance As New Class1()
Dim glyphValues As Byte(,) = class1instance.Recognize(glyphImage, New Rectangle(0, 0, glyphImage.Width, glyphImage.Height), confidence)
另一个选择是使功能共享

public interface interfaceCTCAM
{
int Recognize(UnmanagedImage image, Rectangle rect, out float confidence);

}
public class Class1
{

public byte[,] Recognize(UnmanagedImage image, Rectangle rect, out float confidence)
{

int glyphSize = 5;
int glyphStartX = rect.Left;
int glyphStartY = rect.Top;
int glyphWidth = rect.Width;
int glyphHeight = rect.Height;
int cellWidth = glyphWidth / glyphSize;
int cellHeight = glyphHeight / glyphSize;
int cellOffsetX = (int)(cellWidth * 0.2);
int cellOffsetY = (int)(cellHeight * 0.2);
int cellScanX = (int)(cellWidth * 0.6);
int cellScanY = (int)(cellHeight * 0.6);
int cellScanArea = cellScanX * cellScanY;
int[,] cellIntensity = new int[glyphSize, glyphSize];
unsafe
{
int stride = image.Stride;
byte* srcBase = (byte*)image.ImageData.ToPointer() +
(glyphStartY + cellOffsetY) * stride +
glyphStartX + cellOffsetX;
byte* srcLine;
byte* src;
for (int gi = 0; gi < glyphSize; gi++)
{
srcLine = srcBase + cellHeight * gi * stride;
for (int y = 0; y < cellScanY; y++)
{
for (int gj = 0; gj < glyphSize; gj++)
{
src = srcLine + cellWidth * gj;
for (int x = 0; x < cellScanX; x++, src++)
{
cellIntensity[gi, gj] += *src;
}
}
srcLine += stride;
}
}
}

// calculate value of each glyph's cell and set
// glyphs' confidence to minim value of cell's confidence
byte[,] glyphValues = new byte[glyphSize, glyphSize];
confidence = 1f;
for (int gi = 0; gi < glyphSize; gi++)
{
for (int gj = 0; gj < glyphSize; gj++)
{
float fullness = (float)
(cellIntensity[gi, gj] / 255) / cellScanArea;
float conf = (float)System.Math.Abs(fullness - 0.5) + 0.5f;
glyphValues[gi, gj] = (byte)((fullness > 0.5f) ? 1 : 0);
if (conf < confidence)
confidence = conf;
}
}
return glyphValues;
}

}
Dim glyphValues As Byte(,) = Recognize(glyphImage, New Rectangle(0, 0, glyphImage.Width, glyphImage.Height), confidence)
Dim class1instance As New Class1()
Dim glyphValues As Byte(,) = class1instance.Recognize(glyphImage, New Rectangle(0, 0, glyphImage.Width, glyphImage.Height), confidence)