簡體   English   中英

MVC Web服務返回-32位過程中不支持Microsoft SharePoint

[英]MVC Web Service returns - Microsoft SharePoint is not supported in 32-bit process

我正在嘗試實現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位模式運行該項目,但是如果選擇該選項,則該項目將無法運行。 我還發現,無法選中“首選32位”選項,但該選項被禁用且未選中,最后在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.Administration.SPConfigurationDatabase.get_RegistryConnectionString()在Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_Local()在Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_RegistryConnectionString()在Microsoft.SharePoint.Administration.SPFarm.FindLocal(SPFarm&farm, Microsoft.SharePoint.Administration.SPFarm.get_Local()(Microsoft.SharePoint.SPSite..ctor(String requestUrl)上的Boolean&isJoined)SPDocumentAPI.Controllers.DocumentController.Get(String docId,String docName,String docLibrary,String newDocLibrary)

在應用程序屬性中的x64平台下構建應用程序時出現錯誤消息

無法加載文件或程序集“ SPDocumentAPI”或其依賴項之一。 試圖加載格式錯誤的程序。

堆棧跟蹤

[BadImageFormatException:無法加載文件或程序集'SPDocumentAPI'或其依賴項之一。 試圖以錯誤的格式加載程序。] System.Reflection.RuntimeAssembly._nLoad(AssemblyName文件名,字符串codeBase,證據AssemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布爾throwOnFileNotFound,布爾值用於Introspection,布爾值抑制) 0 System.Reflection.RuntimeAssembly.nLoad(AssemblyName文件名,字符串codeBase,證據assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布爾throwOnFileNotFound,布爾值用於自省,布爾抑制安全性檢查)+152 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecuri ty,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,用於自省的布爾值)+77 System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString,證據assemblySecurity,StackCrawlMark&stackMark,用於自省的布爾值)+16 System.Reflection.Assembly.Load(字符串assemblyString)+28 Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+38

[ConfigurationErrorsException:無法加載文件或程序集'SPDocumentAPI'或其依賴項之一。 試圖加載格式不正確的程序。] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串assemblyName,布爾型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.CallPrePath ,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 appDomain)

[HttpException(0x80004005):無法加載文件或程序集'SPDocumentAPI'或其依賴項之一。 試圖加載格式錯誤的程序。] System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+9915300 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文)+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr ,HttpContext上下文)+254

很好,該項目正在IIS Express上運行,並且IIS Express似乎無法在Visual Studio 2012上編譯64位應用程序。

我發現此鏈接說明了如何向注冊表添加一些更改。

最后,只需在命令提示符下運行以下代碼,然后重新啟動服務器即可。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM