【问题标题】:MVC Web Service returns - Microsoft SharePoint is not supported in 32-bit processMVC Web 服务返回 - 32 位进程不支持 Microsoft SharePoint
【发布时间】:2014-05-10 23:45:25
【问题描述】:

我正在尝试实施 DocX 以使用 Web 服务替换 Sharepoint 中文档库中文档的信息。我遇到了困难,因为当我运行我的项目并尝试将信息发送到 api 地址时,我收到以下错误

Microsoft SharePoint is not supported in 32-bit process. Please verify that you are running in a 64-bit executable. 

在调试时代码在以下行中断

 using (SPSite site = new SPSite(siteurl))

我发现我需要在 64 位模式下运行项目,但如果我选择该选项,项目将不会运行。我还发现无法选中 Prefer 32bit 选项,但该选项已禁用且未选中,最后在 IIS 应用程序池高级设置中,我需要将选项启用 32 位应用程序设置为 true,但它没有执行任何操作。

之前没有一个对我有用,我想寻求一些帮助来解决这个问题。

我正在开发 Sharepoint 2013、Visual Studio 2012 和 MVC 4。

编辑 -

API函数

public class DocumentController : ApiController
{

    public DocModel Get(string docId, string docName, string docLibrary, string newDocLibrary)
    {
        DocModel document = new DocModel();

        try
        {
            string siteurl = "http://win-n1ni65gppp2/";
            using (SPSite site = new SPSite(siteurl))
            {
                using (SPWeb web = site.OpenWeb())
                {}

    }
        catch (Exception ex)
        {
            document.Message = ex.ToString() + "Perdistes";
            Console.Write(ex);
        }

        return document;
    }

}

应用程序在任何 CPU 上时的异常消息

System.PlatformNotSupportedException:32 位进程不支持 Microsoft SharePoint。请确认您在 64 位可执行文件中运行。在 Microsoft.SharePoint.Utilities.SPUtility.CheckFrameworkAndProcess() 在 Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_RegistryConnectionString() 在 Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_Local() 在 Microsoft.SharePoint.Administration.SPFarm.FindLocal(SPFarm& farm, Boolean& isJoined) 在 Microsoft.SharePoint.Administration.SPFarm.get_Local() 在 Microsoft.SharePoint.SPSite..ctor(String requestUrl) 在 SPDocumentAPI.Controllers.DocumentController.Get(String docId, String docName, String docLibrary, String newDocLibrary)

应用程序属性中在 x64 平台下构建应用程序时的错误消息

无法加载文件或程序集“SPDocumentAPI”或其依赖项之一。试图加载格式不正确的程序。

堆栈跟踪

[BadImageFormatException:无法加载文件或程序集“SPDocumentAPI”或其依赖项之一。试图加载格式不正确的程序。] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0 System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据 assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark 和 stackMark,IntPtr pPrivHostBinder,布尔 throwOnFileNotFound,布尔 forIntrospection,布尔 suppressSecurityChecks)+152 System.Reflection.RuntimeAssembly.InternalLoad(字符串 assemblyString,证据 assemblySecurity,StackCrawlMark 和 stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection)+77 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean for Introspection) +16 System.Reflection.Assembly.Load(String assemblyString) +28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException:无法加载文件或程序集“SPDocumentAPI”或其依赖项之一。试图加载格式不正确的程序。] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285 System.Web.Compilation.BuildManager.ExecutePreAppStart() +153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516

[HttpException (0x80004005): 无法加载文件或程序集“SPDocumentAPI”或其依赖项之一。试图加载格式不正确的程序。] System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文) +9915300 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文)+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

【问题讨论】:

  • 这是服务器端代码,SharePoint 是 64 位应用程序。您是否将服务器端库添加到您的应用程序?如果您这样做了,您的应用程序必须是 64 位的并且位于与 Sharepoint 相同的服务器上
  • 是的,我的服务器是 64 位,Sharepoint 2013 是 64 位,Visual Studio 2012 版本是 64 位,我在同一台服务器上开发。至于图书馆,我只使用 Microsoft.Sharepoint。
  • Web 应用程序 必须是 64 位,因为 Microsoft.SharePoint 是服务器端库。代码在哪里,编译/运行时错误是什么?
  • Web 应用程序在任何 CPU 上运行,但未选中 Prefer 32bit。如果我将应用程序设置为 64 位,则根本不打开。我将在主帖上发布异常消息和堆栈跟踪
  • 什么是 SPDocumentAPI? SharePoint 没有这样的库,任何第三方库无论如何都会编译为 x64。如果它是您解决方案中的另一个项目,它也必须设置为 x64

标签: c# sharepoint


【解决方案1】:

项目在 IIS Express 上运行,而且似乎 IIS Express 无法在 Visual Studio 2012 上编译 64 位应用程序。

我发现this link 解释了如何向注册表添加一些更改。

最后只需在命令提示符下运行以下代码并重新启动服务器。

reg add HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\WebProjects /v Use64BitIISExpress /t REG_DWORD /d 1

【讨论】:

    猜你喜欢
    • 2014-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-15
    • 1970-01-01
    • 2020-01-27
    • 2023-03-04
    • 1970-01-01
    相关资源
    最近更新 更多