找回密码
 立即注册

QQ登录

只需一步,快速开始

newdimchina

银牌会员

3

主题

11

帖子

2237

积分

银牌会员

积分
2237

活字格认证

最新发帖
newdimchina
银牌会员   /  发表于:2013-4-17 17:42  /   查看:7673  /  回复:8
在我用mfc调用的winform程序dll的时候,会报没有spread。net license,有没有解决方法!
如图:
error.jpg (56.78 KB, 下载次数: 765)

8 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-4-18 08:54:00
沙发
回复 1楼newdimchina的帖子

newdimchina 你好,

Spread .NET 6 基于 .NET 平台开发,我们推荐用户在 .NET 平台下使用。

在 C++ 中可以使用 Spread COM 版本,产品功能请浏览:
http://www.gcpowertools.com.cn/products/Spcom_overview.htm

以上,
谢谢
回复 使用道具 举报
newdimchina
银牌会员   /  发表于:2013-4-18 09:04:00
板凳
回复 2楼iceman的帖子

这样啊,因为Spread COM支持的Excel公式等功能没有 .NET强大,我们才选择.NET的。
这样的话,是不是没有其他方法了。
谢谢回复~
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-4-18 14:05:00
地板
回复 3楼newdimchina的帖子

newdimchina 你好,
我这里可以提供一种通用的方法你可以尝试。
在 C++ 中创建 AppDomainSetup 创建托管环境,通过AppDomainSetup 下 LicenseFile 属性去引用 license 文件。
可以根据链接中资源去实现在 C++ 中引用 license 文件:http://technet.microsoft.com/zh- ... .appdomain.evidence(VS.90).aspx
代码如下:
  1. Visual C++
  2. using namespace System;
  3. using namespace System::Reflection;
  4. using namespace System::Security::Policy;
  5. //for evidence object
  6. using namespace System::Security;
  7. //for securityzone object
  8. using namespace System::Collections;

  9. //for IEnumerator
  10. int main()
  11. {

  12.    // Create appdomainsetup information for the new appdomain.
  13.    AppDomainSetup^ domaininfo = gcnew AppDomainSetup;
  14.    domaininfo->ApplicationBase = System::Environment::CurrentDirectory;
  15.    domaininfo->ConfigurationFile = System::Environment::CurrentDirectory + "\\ADCreateDomain.exe.config";
  16.    domaininfo->ApplicationName = "MyApplication";
  17.    domaininfo->LicenseFile = System::Environment::CurrentDirectory + "\\license.txt";

  18.    //Create evidence for new appdomain.
  19.    Evidence^ adevidence = AppDomain::CurrentDomain->Evidence;

  20.    //Add the zone and url information to restrict permissions assigned to the appdomain.
  21.    adevidence->AddHost( gcnew Url( "http://www.example.com" ) );
  22.    adevidence->AddHost( gcnew Zone( SecurityZone::Internet ) );

  23.    // Create the application domain.
  24.    AppDomain^ newDomain = AppDomain::CreateDomain( "MyDomain", adevidence, domaininfo );

  25.    // Write out the application domain information.
  26.    Console::WriteLine( "Host domain: {0}", AppDomain::CurrentDomain->FriendlyName );
  27.    Console::WriteLine( "child domain: {0}", newDomain->FriendlyName );
  28.    Console::WriteLine();
  29.    Console::WriteLine( "Application base is: {0}", newDomain->SetupInformation->ApplicationBase );
  30.    Console::WriteLine( "Configuration file is: {0}", newDomain->SetupInformation->ConfigurationFile );
  31.    Console::WriteLine( "Application name is: {0}", newDomain->SetupInformation->ApplicationName );
  32.    Console::WriteLine( "License file is: {0}", newDomain->SetupInformation->LicenseFile );
  33.    IEnumerator^ newevidenceenum = newDomain->Evidence->GetEnumerator();
  34.    while ( newevidenceenum->MoveNext() )
  35.       Console::WriteLine( newevidenceenum->Current );

  36.    AppDomain::Unload( newDomain );
  37. }
复制代码
回复 使用道具 举报
newdimchina
银牌会员   /  发表于:2013-4-18 16:20:00
5#
回复 4楼iceman的帖子

ADCreateDomain.exe.config没有这个文件啊,
AppDomain^ newDomain = AppDomain::CreateDomain( "MyDomain", adevidence, domaininfo );我得到的newDomain 属性值倒是error的,我是再mfc中添加的
  1. BOOL Ctest_for_csharp_dllApp::InitInstance()
  2. {
  3.         // InitCommonControlsEx() is required on Windows XP if an application
  4.         // manifest specifies use of ComCtl32.dll version 6 or later to enable
  5.         // visual styles.  Otherwise, any window creation will fail.
  6.         INITCOMMONCONTROLSEX InitCtrls;
  7.         InitCtrls.dwSize = sizeof(InitCtrls);
  8.         // Set this to include all the common control classes you want to use
  9.         // in your application.
  10.         InitCtrls.dwICC = ICC_WIN95_CLASSES;
  11.         InitCommonControlsEx(&InitCtrls);
  12.         CWinAppEx::InitInstance();
  13.         AfxEnableControlContainer();
  14.         // Standard initialization
  15.         // If you are not using these features and wish to reduce the size
  16.         // of your final executable, you should remove from the following
  17.         // the specific initialization routines you do not need
  18.         // Change the registry key under which our settings are stored
  19.         // TODO: You should modify this string to be something appropriate
  20.         // such as the name of your company or organization
  21.         SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  22.         AppDomainSetup^ domaininfo = gcnew AppDomainSetup;
  23.         domaininfo->ApplicationBase = System::Environment::CurrentDirectory;
  24.         domaininfo->ConfigurationFile = System::Environment::CurrentDirectory + "\\ADCreateDomain.exe.config";
  25.         domaininfo->ApplicationName = "test_for_csharp_dll";
  26.         domaininfo->LicenseFile = System::Environment::CurrentDirectory + "\\licenses.txt";
  27.         //Create evidence for new appdomain.
  28.         Evidence^ baseEvidence = AppDomain::CurrentDomain->Evidence;
  29.         Evidence^ adevidence = gcnew Evidence( baseEvidence );
  30.         //Add the zone and url information to restrict permissions assigned to the appdomain.
  31.         adevidence->AddHost( gcnew Url( "http://www.example.com" ) );
  32.         adevidence->AddHost( gcnew Zone( SecurityZone::Internet ) );
  33.         // Create the application domain.
  34.         AppDomain^ newDomain = AppDomain::CreateDomain( "MyDomain", adevidence, domaininfo );
  35.        
  36.         // Write out the application domain information.
  37.         Console::WriteLine( "Host domain: {0}", AppDomain::CurrentDomain->FriendlyName );
  38.         Console::WriteLine( "child domain: {0}", newDomain->FriendlyName );
  39.         Console::WriteLine();
  40.         Console::WriteLine( "Application base is: {0}", newDomain->SetupInformation->ApplicationBase );
  41.         Console::WriteLine( "Configuration file is: {0}", newDomain->SetupInformation->ConfigurationFile );
  42.         Console::WriteLine( "Application name is: {0}", newDomain->SetupInformation->ApplicationName );
  43.         Console::WriteLine( "License file is: {0}", newDomain->SetupInformation->LicenseFile );
  44.         IEnumerator^ newevidenceenum = newDomain->Evidence->GetEnumerator();
  45.         while ( newevidenceenum->MoveNext() )
  46.                 Console::WriteLine( newevidenceenum->Current );
  47.         Ctest_for_csharp_dllDlg dlg;
  48.         m_pMainWnd = &dlg;
  49.         INT_PTR nResponse = dlg.DoModal();
  50.         if (nResponse == IDOK)
  51.         {
  52.                 // TODO: Place code here to handle when the dialog is
  53.                 //  dismissed with OK
  54.         }
  55.         else if (nResponse == IDCANCEL)
  56.         {
  57.                 // TODO: Place code here to handle when the dialog is
  58.                 //  dismissed with Cancel
  59.         }
  60.          AppDomain::Unload( newDomain );
  61.         // Since the dialog has been closed, return FALSE so that we exit the
  62.         //  application, rather than start the application's message pump.
  63.         return FALSE;
  64. }
复制代码
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-4-19 10:47:00
6#
回复 5楼newdimchina的帖子

Spread .NET 版本没有在 MFC 环境下经过严格的测试,我们一般不推荐用户如此使用,
从提示看是程序集引用问题,可以在网上搜索一些参考资源。
回复 使用道具 举报
newdimchina
银牌会员   /  发表于:2013-4-23 11:37:00
7#
回复 6楼iceman的帖子

嗯,已经决定不这样做的,非常感谢~
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-4-23 14:18:00
8#
回复 7楼newdimchina的帖子

好的 如果有其他问题 欢迎继续交流。
回复 使用道具 举报
Pt_Hoffmann
新手上路   /  发表于:2014-3-18 13:54:00
9#
在MFC App中使用 spread .net for winform 是可行的,我实际做过。
我也遇到过你这个license报错的问题。后来想办法绕过去了。
spread superman
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部