0
這是我的接口和類命名DataAccess.cs如何清除使用C#DLL在VC
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Data.Common;
using System.Linq;
using Microsoft.Practices.EnterpriseLibrary.Data;
using IISWebFrameworkDAAB.BusinessLayer;
using IISWebFrameworkDAAB.DataAccessLayer;
using Framework.Data;
using System.Text;
namespace IISWebFrameworkDAAB.DataAccessLayer
{
[Guid("76f20d76-b030-4487-a315-2d727dedd4ec")]
public interface DataAccessInterface
{
#region "Methods"
void InsertSampleTable(Byte varTinyInt, Int32 varInt, String varText, String varVarchar, Boolean varBit, DateTime varDateTime, Decimal varDecimal);
};
[Guid("c686d756-98a7-4048-b79c-b1ff9889730c")]
public class DataAccess : DataAccessInterface
{
public void InsertSampleTable(Byte varTinyInt, Int32 varInt, String varText, String varVarchar, Boolean varBit, DateTime varDateTime, Decimal varDecimal)
{
m_procName = "Insert_SampleTable";
m_dbCommand = m_db.GetStoredProcCommand(m_procName);
m_db.AddInParameter(m_dbCommand, "_varTinyInt", DbType.Byte, varTinyInt);
m_db.AddInParameter(m_dbCommand, "_varInt", DbType.Int32, varInt);
m_db.AddInParameter(m_dbCommand, "_varText", DbType.String, varText);
m_db.AddInParameter(m_dbCommand, "_varVarchar", DbType.String, varVarchar);
m_db.AddInParameter(m_dbCommand, "_varBit", DbType.Boolean, varBit);
m_db.AddInParameter(m_dbCommand, "_varDateTime", DbType.DateTime, varDateTime);
m_db.AddInParameter(m_dbCommand, "_varDecimal", DbType.Decimal, varDecimal);
m_db.ExecuteNonQuery(m_dbCommand);
}
};
}
這是我的AssemblyInfo.cs
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("IISWebFrameworkDAAB")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IISWebFrameworkDAAB")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
//[assembly: ComVisible(false)]
[assembly: ComVisible(true)]
[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("..\\..\\MyKeyFile.SNK")]
// The following GUID is for the ID of the typelib if this project is exposed to COM
// [組件的錯誤:GUID( 「76f20d76-b030-4487-a315-2d727dedd4ec」)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
這是我的客戶: -
#include <windows.h>
#include <stdio.h>
#pragma warning (disable: 4278)
// To use managed-code servers like the C# server,
// we have to import the common language runtime:
#import <mscorlib.tlb> //raw_interfaces_only
#import "C:\Documents and Settings\Administrator\Desktop\new\NiproDAAB\IISWebFrameworkDAAB\bin\Debug\IISWebFrameworkDAAB.tlb"
using namespace IISWebFrameworkDAAB;
int main(int argc, char* argv[])
{
DataAccessInterface *cpi = NULL;
int retval = 1;
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(CLSID_DataAccess,
NULL, CLSCTX_INPROC_SERVER,
IID_DataAccessInterface, reinterpret_cast<void**>(&cpi));
if (FAILED(hr))
{
printf("Couldn't create the instance!... 0x%x\n", hr);
}
}
當我運行客戶端,我得到了以下錯誤: -
error C2065: 'CLSID_DataAccess' : undeclared identifier
1>c:\documents and settings\administrator\my documents\visual studio 2010\projects\connectdll\connectdll\cli.cpp(19): error C2065: 'IID_DataAccessInterface' : undeclared identifier
我做,因爲它是以下鏈接給出http://msdn.microsoft.com/en-us/library/aa645738%28v=vs.71%29.aspx
我收到一個錯誤,「entlibcontrib .data.mysql」沒有一個強名稱 – Dany