Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
0xc000007b错误-但所有DLL均为32位 < >我使用Visual Studio 2008在Windows 7位操作系统上编译我的C++代码,使用.NET框架3.5。p>_Windows_Visual Studio 2008_Clr - Fatal编程技术网

0xc000007b错误-但所有DLL均为32位 < >我使用Visual Studio 2008在Windows 7位操作系统上编译我的C++代码,使用.NET框架3.5。p>

0xc000007b错误-但所有DLL均为32位 < >我使用Visual Studio 2008在Windows 7位操作系统上编译我的C++代码,使用.NET框架3.5。p>,windows,visual-studio-2008,clr,Windows,Visual Studio 2008,Clr,所有DLL均为32位(使用Dependency Walker进行验证) 根据我的研究,当32位代码调用64位DLL时会出现这个错误,但这里不是这样 是否存在错误0xc000007b的其他根本原因 要使用.NET FW 4.0,应使用旧版激活垫片代码将.NET FW作为COM组件加载 进入您的托管应用程序,如下所示: 使用宏 #define LEGACY_ACTIVATION_SHIM_ALLOW_LEGACY_API_FALLBACK Sudoku.Runtime.h: #pragma onc

所有DLL均为32位(使用Dependency Walker进行验证)

根据我的研究,当32位代码调用64位DLL时会出现这个错误,但这里不是这样


是否存在错误0xc000007b的其他根本原因

要使用.NET FW 4.0,应使用旧版激活垫片代码将.NET FW作为COM组件加载 进入您的托管应用程序,如下所示:

使用宏

#define LEGACY_ACTIVATION_SHIM_ALLOW_LEGACY_API_FALLBACK
Sudoku.Runtime.h:

#pragma once
// 
extern "C" int wWinMainCRTStartup();
// Sudoku.Runtime.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int _runtime()
{
    wWinMainCRTStartup();
    return 0;
}

int APIENTRY _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
    try
    {
        //CoInitializeEx(NULL, 0);              
        //CoUninitialize();
        HRESULT hr;     
        ICorRuntimeHost *pHost = NULL;
        hr = LegacyActivationShim::CorBindToRuntimeEx(NULL, NULL, STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST, CLSID_CorRuntimeHost, IID_ICorRuntimeHost, reinterpret_cast<LPVOID*>(&pHost));
        if (!FAILED(hr))
        {
            IUnknown *pAppDomainPunk = NULL;
            hr = pHost->CreateDomainEx(TEXT("_runtime"), NULL, NULL, &pAppDomainPunk);
            if (!FAILED(hr))
            {
                _::_AppDomain *pDefaultDomain = NULL;
                hr = pAppDomainPunk->QueryInterface(__uuidof(_::_AppDomain), reinterpret_cast<LPVOID*>(&pDefaultDomain));
                if (!FAILED(hr))
                {
                    _::_ObjectHandle *pObjHandle = NULL;
                    hr = pDefaultDomain->CreateInstance(_bstr_t("Sudoku"), _bstr_t("Sudoku.Runtime"), &pObjHandle); 
                    if (!FAILED(hr))
                    {
                        VARIANT v;
                        VariantInit(&v);
                        hr = pObjHandle->Unwrap(&v);
                        if (!FAILED(hr))
                        {
                            _::IRuntime *pRemotingHost = NULL;
                            hr = v.pdispVal->QueryInterface(__uuidof(_::IRuntime), (void**) &pRemotingHost);    
                            if (!FAILED(hr))
                            {
                                ::System::Reflection::Assembly^ ra = Assembly::GetExecutingAssembly();
                                array<::System::Byte>^ bytes = ra->GetName()->GetPublicKeyToken();
                                SAFEARRAY *psa = SafeArrayCreateVector(VT_UI1, 0, bytes->Length);
                                BYTE *pData;
                                hr = SafeArrayAccessData(psa, (void **)&pData);
                                if (!FAILED(hr))
                                {
                                    for(int i=0; i < bytes->Length; i++) pData[i] = bytes[i];
                                    hr = SafeArrayUnaccessData(psa);
                                    if (!FAILED(hr))
                                    {
                                        pRemotingHost->Run(psa);
                                    }
                                    pHost->UnloadDomain(pAppDomainPunk);
                                }
                            }
                            pObjHandle->Release();
                        }
                        pDefaultDomain->Release();
                    }
                    pAppDomainPunk->Release();
                }
                pHost->Release();
            }
            LegacyActivationShim::CorExitProcess(0);
        }
    }
    catch(...)
    {
    }
    return 0;
}
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"
// TODO: reference additional headers your program requires here

// Exclude rarely-used stuff from Windows headers
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN   

#import <mscorlib.tlb> auto_rename \
    rename("value", "___value") \
    rename("ReportEvent", "___ReportEvent") \
    rename_namespace("_") \
    raw_interfaces_only \
    high_property_prefixes("_get","_put","_putref")

#import "..\\Public\\Sudoku.tlb" auto_rename \
    rename_namespace("_") \
    raw_interfaces_only \
    high_property_prefixes("_get","_put","_putref")

// C RunTime Header Files
#include <tchar.h>

#include "cor.h"
#include "mscoree.h"
#include "strongname.h"

#include "Sudoku.Runtime.h"
#include "AssemblyInfo.h"
#include "Resource.h"


#define LEGACY_ACTIVATION_SHIM_ALLOW_LEGACY_API_FALLBACK

#include "LegacyActivationShimDelayLoad.h"
// ==++==
// 
//   Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// ==--==
//
// LegacyActivationShim.h
//
// This file allows simple migration from .NET Runtime v2 Host Activation APIs
// to the .NET Runtime v4 Host Activation APIs through simple shim functions.
// To use, just include this header file after the header file that declares the
// deprecated APIs you are using, and append the "LegacyActivationShim::" namespace
// in front of all deprecated API calls.
//
// For example,
//      #include "mscoree.h"
//      ...
//      CorBindToRuntimeEx(
//          NULL, NULL, 0, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (LPVOID *)&pRH));
// becomes
//      #include "mscoree.h"
//      #include "LegacyActivationShim.h"
//      ...
//      LegacyActivationShim::CorBindToRuntimeEx(
//          NULL, NULL, 0, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (LPVOID *)&pRH));
//
// To enable fallback to the legacy APIs when v4.0 is not installed on the machine,
// define LEGACY_ACTIVATION_SHIM_ALLOW_LEGACY_API_FALLBACK before including this
// header file.
//
// To use the legacy API fallback in a delay-loaded fashion, include LegacyActivationShimDelayLoad.h
// instead.
//
[Serializable]
[ComVisible(true)]
[Obfuscation(Exclude = true)]
public class Runtime : IRuntime
{    
    public void Run(byte[] publikKeyToken)
    {
        Application.Run(publikKeyToken);
    }
}

[ComVisible(true)]
[Obfuscation(Exclude = true)]
public interface IRuntime
{
    void Run(byte[] publikKeyToken);
}
Sudoku.Runtime.cpp:

#pragma once
// 
extern "C" int wWinMainCRTStartup();
// Sudoku.Runtime.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int _runtime()
{
    wWinMainCRTStartup();
    return 0;
}

int APIENTRY _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
    try
    {
        //CoInitializeEx(NULL, 0);              
        //CoUninitialize();
        HRESULT hr;     
        ICorRuntimeHost *pHost = NULL;
        hr = LegacyActivationShim::CorBindToRuntimeEx(NULL, NULL, STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST, CLSID_CorRuntimeHost, IID_ICorRuntimeHost, reinterpret_cast<LPVOID*>(&pHost));
        if (!FAILED(hr))
        {
            IUnknown *pAppDomainPunk = NULL;
            hr = pHost->CreateDomainEx(TEXT("_runtime"), NULL, NULL, &pAppDomainPunk);
            if (!FAILED(hr))
            {
                _::_AppDomain *pDefaultDomain = NULL;
                hr = pAppDomainPunk->QueryInterface(__uuidof(_::_AppDomain), reinterpret_cast<LPVOID*>(&pDefaultDomain));
                if (!FAILED(hr))
                {
                    _::_ObjectHandle *pObjHandle = NULL;
                    hr = pDefaultDomain->CreateInstance(_bstr_t("Sudoku"), _bstr_t("Sudoku.Runtime"), &pObjHandle); 
                    if (!FAILED(hr))
                    {
                        VARIANT v;
                        VariantInit(&v);
                        hr = pObjHandle->Unwrap(&v);
                        if (!FAILED(hr))
                        {
                            _::IRuntime *pRemotingHost = NULL;
                            hr = v.pdispVal->QueryInterface(__uuidof(_::IRuntime), (void**) &pRemotingHost);    
                            if (!FAILED(hr))
                            {
                                ::System::Reflection::Assembly^ ra = Assembly::GetExecutingAssembly();
                                array<::System::Byte>^ bytes = ra->GetName()->GetPublicKeyToken();
                                SAFEARRAY *psa = SafeArrayCreateVector(VT_UI1, 0, bytes->Length);
                                BYTE *pData;
                                hr = SafeArrayAccessData(psa, (void **)&pData);
                                if (!FAILED(hr))
                                {
                                    for(int i=0; i < bytes->Length; i++) pData[i] = bytes[i];
                                    hr = SafeArrayUnaccessData(psa);
                                    if (!FAILED(hr))
                                    {
                                        pRemotingHost->Run(psa);
                                    }
                                    pHost->UnloadDomain(pAppDomainPunk);
                                }
                            }
                            pObjHandle->Release();
                        }
                        pDefaultDomain->Release();
                    }
                    pAppDomainPunk->Release();
                }
                pHost->Release();
            }
            LegacyActivationShim::CorExitProcess(0);
        }
    }
    catch(...)
    {
    }
    return 0;
}
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"
// TODO: reference additional headers your program requires here

// Exclude rarely-used stuff from Windows headers
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN   

#import <mscorlib.tlb> auto_rename \
    rename("value", "___value") \
    rename("ReportEvent", "___ReportEvent") \
    rename_namespace("_") \
    raw_interfaces_only \
    high_property_prefixes("_get","_put","_putref")

#import "..\\Public\\Sudoku.tlb" auto_rename \
    rename_namespace("_") \
    raw_interfaces_only \
    high_property_prefixes("_get","_put","_putref")

// C RunTime Header Files
#include <tchar.h>

#include "cor.h"
#include "mscoree.h"
#include "strongname.h"

#include "Sudoku.Runtime.h"
#include "AssemblyInfo.h"
#include "Resource.h"


#define LEGACY_ACTIVATION_SHIM_ALLOW_LEGACY_API_FALLBACK

#include "LegacyActivationShimDelayLoad.h"
// ==++==
// 
//   Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// ==--==
//
// LegacyActivationShim.h
//
// This file allows simple migration from .NET Runtime v2 Host Activation APIs
// to the .NET Runtime v4 Host Activation APIs through simple shim functions.
// To use, just include this header file after the header file that declares the
// deprecated APIs you are using, and append the "LegacyActivationShim::" namespace
// in front of all deprecated API calls.
//
// For example,
//      #include "mscoree.h"
//      ...
//      CorBindToRuntimeEx(
//          NULL, NULL, 0, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (LPVOID *)&pRH));
// becomes
//      #include "mscoree.h"
//      #include "LegacyActivationShim.h"
//      ...
//      LegacyActivationShim::CorBindToRuntimeEx(
//          NULL, NULL, 0, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (LPVOID *)&pRH));
//
// To enable fallback to the legacy APIs when v4.0 is not installed on the machine,
// define LEGACY_ACTIVATION_SHIM_ALLOW_LEGACY_API_FALLBACK before including this
// header file.
//
// To use the legacy API fallback in a delay-loaded fashion, include LegacyActivationShimDelayLoad.h
// instead.
//
[Serializable]
[ComVisible(true)]
[Obfuscation(Exclude = true)]
public class Runtime : IRuntime
{    
    public void Run(byte[] publikKeyToken)
    {
        Application.Run(publikKeyToken);
    }
}

[ComVisible(true)]
[Obfuscation(Exclude = true)]
public interface IRuntime
{
    void Run(byte[] publikKeyToken);
}
Sudoku.Runtime.cs:

#pragma once
// 
extern "C" int wWinMainCRTStartup();
// Sudoku.Runtime.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int _runtime()
{
    wWinMainCRTStartup();
    return 0;
}

int APIENTRY _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
    try
    {
        //CoInitializeEx(NULL, 0);              
        //CoUninitialize();
        HRESULT hr;     
        ICorRuntimeHost *pHost = NULL;
        hr = LegacyActivationShim::CorBindToRuntimeEx(NULL, NULL, STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST, CLSID_CorRuntimeHost, IID_ICorRuntimeHost, reinterpret_cast<LPVOID*>(&pHost));
        if (!FAILED(hr))
        {
            IUnknown *pAppDomainPunk = NULL;
            hr = pHost->CreateDomainEx(TEXT("_runtime"), NULL, NULL, &pAppDomainPunk);
            if (!FAILED(hr))
            {
                _::_AppDomain *pDefaultDomain = NULL;
                hr = pAppDomainPunk->QueryInterface(__uuidof(_::_AppDomain), reinterpret_cast<LPVOID*>(&pDefaultDomain));
                if (!FAILED(hr))
                {
                    _::_ObjectHandle *pObjHandle = NULL;
                    hr = pDefaultDomain->CreateInstance(_bstr_t("Sudoku"), _bstr_t("Sudoku.Runtime"), &pObjHandle); 
                    if (!FAILED(hr))
                    {
                        VARIANT v;
                        VariantInit(&v);
                        hr = pObjHandle->Unwrap(&v);
                        if (!FAILED(hr))
                        {
                            _::IRuntime *pRemotingHost = NULL;
                            hr = v.pdispVal->QueryInterface(__uuidof(_::IRuntime), (void**) &pRemotingHost);    
                            if (!FAILED(hr))
                            {
                                ::System::Reflection::Assembly^ ra = Assembly::GetExecutingAssembly();
                                array<::System::Byte>^ bytes = ra->GetName()->GetPublicKeyToken();
                                SAFEARRAY *psa = SafeArrayCreateVector(VT_UI1, 0, bytes->Length);
                                BYTE *pData;
                                hr = SafeArrayAccessData(psa, (void **)&pData);
                                if (!FAILED(hr))
                                {
                                    for(int i=0; i < bytes->Length; i++) pData[i] = bytes[i];
                                    hr = SafeArrayUnaccessData(psa);
                                    if (!FAILED(hr))
                                    {
                                        pRemotingHost->Run(psa);
                                    }
                                    pHost->UnloadDomain(pAppDomainPunk);
                                }
                            }
                            pObjHandle->Release();
                        }
                        pDefaultDomain->Release();
                    }
                    pAppDomainPunk->Release();
                }
                pHost->Release();
            }
            LegacyActivationShim::CorExitProcess(0);
        }
    }
    catch(...)
    {
    }
    return 0;
}
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"
// TODO: reference additional headers your program requires here

// Exclude rarely-used stuff from Windows headers
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN   

#import <mscorlib.tlb> auto_rename \
    rename("value", "___value") \
    rename("ReportEvent", "___ReportEvent") \
    rename_namespace("_") \
    raw_interfaces_only \
    high_property_prefixes("_get","_put","_putref")

#import "..\\Public\\Sudoku.tlb" auto_rename \
    rename_namespace("_") \
    raw_interfaces_only \
    high_property_prefixes("_get","_put","_putref")

// C RunTime Header Files
#include <tchar.h>

#include "cor.h"
#include "mscoree.h"
#include "strongname.h"

#include "Sudoku.Runtime.h"
#include "AssemblyInfo.h"
#include "Resource.h"


#define LEGACY_ACTIVATION_SHIM_ALLOW_LEGACY_API_FALLBACK

#include "LegacyActivationShimDelayLoad.h"
// ==++==
// 
//   Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// ==--==
//
// LegacyActivationShim.h
//
// This file allows simple migration from .NET Runtime v2 Host Activation APIs
// to the .NET Runtime v4 Host Activation APIs through simple shim functions.
// To use, just include this header file after the header file that declares the
// deprecated APIs you are using, and append the "LegacyActivationShim::" namespace
// in front of all deprecated API calls.
//
// For example,
//      #include "mscoree.h"
//      ...
//      CorBindToRuntimeEx(
//          NULL, NULL, 0, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (LPVOID *)&pRH));
// becomes
//      #include "mscoree.h"
//      #include "LegacyActivationShim.h"
//      ...
//      LegacyActivationShim::CorBindToRuntimeEx(
//          NULL, NULL, 0, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (LPVOID *)&pRH));
//
// To enable fallback to the legacy APIs when v4.0 is not installed on the machine,
// define LEGACY_ACTIVATION_SHIM_ALLOW_LEGACY_API_FALLBACK before including this
// header file.
//
// To use the legacy API fallback in a delay-loaded fashion, include LegacyActivationShimDelayLoad.h
// instead.
//
[Serializable]
[ComVisible(true)]
[Obfuscation(Exclude = true)]
public class Runtime : IRuntime
{    
    public void Run(byte[] publikKeyToken)
    {
        Application.Run(publikKeyToken);
    }
}

[ComVisible(true)]
[Obfuscation(Exclude = true)]
public interface IRuntime
{
    void Run(byte[] publikKeyToken);
}

正好解决了这个问题。 这个错误似乎不仅是因为在32位代码中混合了64位库,而且是因为库被弄乱了——在我的例子中,我使用的是二进制PCRE库


我自己用MingW构建了PCRE,现在一切都很好

针对完全不同的机器体系结构(如安腾)的DLL。你至少认识那个捣蛋鬼吗?查看输出窗口。