gpt4 book ai didi

c# - MVC Web 服务返回 - 32 位进程不支持 Microsoft SharePoint

转载 作者:行者123 更新时间:2023-12-02 04:32:15 25 4
gpt4 key购买 nike

我正在尝试使用 Web 服务实现 DocX 来替换 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: Microsoft SharePoint is not supported in 32-bit process. Please verify that you are running in a 64-bit executable. at Microsoft.SharePoint.Utilities.SPUtility.CheckFrameworkAndProcess() at Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_RegistryConnectionString() at Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_Local() at Microsoft.SharePoint.Administration.SPFarm.FindLocal(SPFarm& farm, Boolean& isJoined) at Microsoft.SharePoint.Administration.SPFarm.get_Local() at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at SPDocumentAPI.Controllers.DocumentController.Get(String docId, String docName, String docLibrary, String newDocLibrary)

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

Could not load file or assembly 'SPDocumentAPI' or one of its dependencies. An attempt was made to load a program with an incorrect format.

堆栈跟踪

[BadImageFormatException: Could not load file or assembly 'SPDocumentAPI' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 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, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16 System.Reflection.Assembly.Load(String assemblyString) +28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'SPDocumentAPI' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 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): Could not load file or assembly 'SPDocumentAPI' or one of its dependencies. An attempt was made to load a program with an incorrect format.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9915300 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

最佳答案

该项目在 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

关于c# - MVC Web 服务返回 - 32 位进程不支持 Microsoft SharePoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22764925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com