编译C#ClassLib以在Access 2010 x64中使用 [英] Compiling C# ClassLib for use in Access 2010 x64

查看:47
本文介绍了编译C#ClassLib以在Access 2010 x64中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HEllo,


 


一直试图编译测试c#脚本以便在Access 2010 x64中使用


MEthod  1) 




平台目标x86


Com interop Selected 


编译好并创建.DLL& TLB


 


访问结果2010 x64:


无法创建ActiveX对象


结果在访问2003 x86 


工作


方法2) 


平台目标x64


Com interop选择 


结果。不编译 


xyz  无效汇编 


No Tlb Created


 


 



MEthod 3) 



Platform Target x64



Com interop UnSelected 


Postbuild : "%WINDIR%\Microsoft.NET\Framework64\v2.0.50727\regasm" "$(TargetPath)  


结果。编译 


但没有TLB  


 


 


 



MEthod 4) 



Platform Target x64



Com interop UnSelected 


Postbuild: "%Windir%\ Mesrosoft.NET \ Framework64 \v2.0.50727 \ regasm" "$(TargetPath)  


"%Windir%\ Microsrosoft.NET \ Framework64 \v2.0.50727 \ regasm" " $(TARGETPATH)" / tlb:$(TargetName)" .tlb" 



结果。编译 


TLB已创建。


在访问中测试2010 x64


 自动化错误系统无法找到指定的文件。


 


 


 


我已经检查过proc mon并且说实话我不会看到abotu我所看到的。 soemthign看起来很奇怪,因为参考dll(64位)是在inprocserver32中我也有几个事件没有找到result = name。 


 


我希望有人可以对此有所了解,并建议正确的方法。


 


谢谢


 


CC


 


 


 

解决方案

正如所说的非常简单的代码只是为了测试让com工作的能力访问... 


 


访问代码为:


'''''' '''$'


Private Sub Command1_Click()


 


Dim x As CL7.Class1


设置x =新CL7.Class1


'设置x = CreateObject(" CL7.Class1")


MsgBox x.Test2


 


End Sub



 


'''''''''''''''' '''''''


 


C#


 


/////////// /////////////////////////////



使用System;


使用System.Collections.Generic;


使用System.Text;


  ;


namespace ClassLibrary7


{


 


    公共类Class1


     {


 


         public string Test2


         {


            获取


             {


 


                 return" xxx";


 


            }


        }


 


 


    }


}



 


////////////////////////////////////////////////// /////////////


另请注意,我已将新cls7的调用更改为createobject。


我有也强大的命名组件。并在程序集文件夹中删除了一个dll副本。


上述更改的错误与为任何处理器编译时的错误相同,即


 


Active x组件无法创建对象时的错误消息。但是我不确定这只是一只红鲱鱼。


******************


我想知道我是否可能在错误的部分发布可能有人可以提供建议。


 


关心所有.. 


HEllo,

 

Have been strugling trying to compile a test c# script for use in Access 2010 x64

MEthod  1) 


Platform Target x86

Com interop Selected 

Compiles fine and creates .DLL & TLB

 

Result in access 2010 x64:

ActiveX object can not be created

Result In access 2003 x86 

Works

MEthod 2) 

Platform Target x64

Com interop Selected 

Result. DOes not compile 

xyz is not a valid assembly 

No Tlb Created

 

 

MEthod 3) 

Platform Target x64

Com interop UnSelected 

Postbuild: "%Windir%\Microsoft.NET\Framework64\v2.0.50727\regasm" "$(TargetPath)" 

Result. Compiles 

But no TLB 

 

 

 

MEthod 4) 

Platform Target x64

Com interop UnSelected 

Postbuild: "%Windir%\Microsoft.NET\Framework64\v2.0.50727\regasm" "$(TargetPath)" 

"%Windir%\Microsoft.NET\Framework64\v2.0.50727\regasm" "$(TargetPath)" /tlb:$(TargetName)".tlb" 

Result. Compiles 

TLB created.

Test in access 2010 x64

 Automation Error The system cannot find the specified file.

 

 

 

I have checked proc mon and to be honest i dont undestand much abotu what i see. soemthign that looks strange as ref to the dll (64bit) are in inprocserver32 Also I have several events with result = name not found. 

 

I hope somebody can shed some light on this and advise of the correct method.

 

Thanks

 

CC

 

 

 

解决方案

As said its very simple code just to test the ability to get a com to work in Access... 

 

Access code is:

''''''''''''''''''''''''''''''''''''''''''''''

Private Sub Command1_Click()

 

Dim x As CL7.Class1

Set x = New CL7.Class1

'Set x = CreateObject("CL7.Class1")

MsgBox x.Test2

 

End Sub

 

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 

C#

 

////////////////////////////////////////

using System;

using System.Collections.Generic;

using System.Text;

 

namespace ClassLibrary7

{

 

    public class Class1

    {

 

        public string Test2

        {

            get

            {

 

                return "xxx";

 

            }

        }

 

 

    }

}

 

///////////////////////////////////////////////////////////////

Also note I have changed the call from new cls7 to createobject.

I have also strong named the component. and dropped a copy of dll in assemblies folder.

with the above changes the error is the same as when it was compiled for any processor i.e 

 

The error msg when Active x component cannot create object. however am not sure if this is just a red herring.

******************

I am wondering if I may have posted in wrong section maybe somebody can advise.

 

Regards to all.. 


这篇关于编译C#ClassLib以在Access 2010 x64中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆