hresult

Does .NET Standard normalize HResult values across every platform it supports?

你说的曾经没有我的故事 提交于 2019-11-28 03:55:24
问题 I am creating a simple function that creates a random file. To be thread safe, it creates the file in a retry loop and if the file exists it tries again. while (true) { fileName = NewTempFileName(prefix, suffix, directory); if (File.Exists(fileName)) { continue; } try { // Create the file, and close it immediately using (var stream = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write, FileShare.Read)) { break; } } catch (IOException e) { // If the error was because the file exists,

Microsoft.Office.Interop.Excel doesn't work on 64 bit

╄→尐↘猪︶ㄣ 提交于 2019-11-28 00:20:09
问题 I've encountered a problem when developing on MS Visual Web Developer 2008 Express Ed. Developing ASP.NET C# on Windows7 64 bit OS. I'm trying to open an Excel document, but it gives me Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD)) I did configured the build to all processors (Any CPU, x64, x86) but it doesn't work. I searched the answer on the internet but couldn't find out how to handle it. The weird thing is the same code worked on the same

Creating your own HRESULT?

与世无争的帅哥 提交于 2019-11-27 17:31:09
问题 I already have a project that uses a lot of COM, and HRESULTS. Anyways I was wondering if it's possible to define your own HRESULT, AND be able to use the FormatMessage() for our own HRESULT? I dug around and can't find anything. Any ideas? EDIT Basically I want to define a set of my own HRESULTs instead of just returning E_FAIL. Or one of the other generic ones. Like E_FAIL is fine. But let's say I want to point out that for example the Geoprocessing subsystem crashed or the file is an

How do I determine the HResult for a System.IO.IOException?

只谈情不闲聊 提交于 2019-11-27 07:25:19
The System.Exception.HResult property is protected. How can I peek inside an exception and get the HResult without resorting to reflection or other ugly hacks? Here's the situation: I want to write a backup tool, which opens and reads files on a system. I open the file with FileAccess.Read and FileShare.ReadWrite, according to this guidance , because I don't care if the file is open for writing at the time I read it. In some cases, when a file I am reading is open by another app, the System.IO.FileStream.Read() method throws a System.IO.IOException, "The process cannot access the file because

Is there a way to get the string representation of HRESULT value using win API?

喜你入骨 提交于 2019-11-27 07:03:13
Is there a function in win API which can be used to extract the string representation of HRESULT value? The problem is that not all return values are documented in MSDN, for example ExecuteInDefaultAppDomain() function is not documented to return "0x80070002 - The system cannot find the file specified.", however, it does! Therefore, I was wondering whether there is a function to be used in common case. eran You can use _com_error : _com_error err(hr); LPCTSTR errMsg = err.ErrorMessage(); If you don't want to use _com_error for whatever reason, you can still take a look at its source, and see

An error occurred while validating. HRESULT = '8000000A'

て烟熏妆下的殇ゞ 提交于 2019-11-26 19:30:27
I have been receiving this error for a while when using devenv on an automatic build. I have gone through every website I can find, and the usual answers mention refreshing dependencies (Which I believe fixes it for manual deployment, but not for automatic) and removing the source control coding from the projects, which hasn't helped me. The error does not occur every time I build, but it seems random on different deployment projects each time. Does anyone have any advice on why exactly this error occurs and how to go about fixing it? oɔɯǝɹ This is a known issue in Visual Studio 2010 (a race

Is there a way to get the string representation of HRESULT value using win API?

▼魔方 西西 提交于 2019-11-26 17:36:07
问题 Is there a function in win API which can be used to extract the string representation of HRESULT value? The problem is that not all return values are documented in MSDN, for example ExecuteInDefaultAppDomain() function is not documented to return "0x80070002 - The system cannot find the file specified.", however, it does! Therefore, I was wondering whether there is a function to be used in common case. 回答1: You can use _com_error: _com_error err(hr); LPCTSTR errMsg = err.ErrorMessage(); If

Exception from HRESULT: 0x80131047

天大地大妈咪最大 提交于 2019-11-26 16:49:42
问题 i am having this problem whenever i try to debug my project: it's in french, here is "my" translation: "Error while trying to run project: Failed Loading assembly "DBZ buu's Fury Text Editor" or one of it's dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)" can anyone help me please ? Thank you, Omar 回答1: If you are using Assembly.Load() to load file try change it with Assembly.LoadFile() instead. 回答2: Project > Project Properties > Name >

An error occurred while validating. HRESULT = '8000000A'

旧时模样 提交于 2019-11-26 06:15:40
问题 I have been receiving this error for a while when using devenv on an automatic build. I have gone through every website I can find, and the usual answers mention refreshing dependencies (Which I believe fixes it for manual deployment, but not for automatic) and removing the source control coding from the projects, which hasn\'t helped me. The error does not occur every time I build, but it seems random on different deployment projects each time. Does anyone have any advice on why exactly this