interop

Could not load assembly . . Interop.Word Version 14.0.0.0

我怕爱的太早我们不能终老 提交于 2019-12-24 03:47:08
问题 I have a WinForms application written in C# which auto generates letters in Word. The application works fine with client machines that have Office 2010 installed, but not with those machines with Office 2007 installed, when instead I get the following error message - could not load file or assembly 'Microsoft.Office.Interop.Word version=14.0.0 I suspect I need to Add a Reference to an older version of Interop.Word e.g. version=12, but there is no such option in the list of references

How to update the change time of a file from c#?

谁都会走 提交于 2019-12-24 03:39:17
问题 Files can have a change date. This date is not the same as the last modified date or the last access date. Change date is not visible through the UI or .NET API. There a two Win32 functions GetFileInformationByHandleEx for reading and SetFileInformationByHandle for writing file information. I want to read out the change date, add some hours to it, and write the new date back as the change date of the file. For now I have following code: class Program { static void Main(string[] args) { using

Are there any problems when using pure C (not class-wrapped) functions in C++ application?

≯℡__Kan透↙ 提交于 2019-12-24 03:35:10
问题 I am planning to use pure C MPI library in C++ application, I don't want to add unnecessary bloat by running eg. Boost MPI layer that wraps all stuff in the MPI::<func> classes. Is there anything I should be aware of? 回答1: You should wrap all your includes for C-headers in an extern "C" block in order to avoid problems with the name mangling of C++ compilers. extern "C" { // include C-headers } Read more here. 回答2: Not really, as most libraries are prepared to be included in a C++ compiler

Getting InteropServices.SEHException on DllImport routine during debug after migrating project from .NET Framework 3.5 to 4.0

ⅰ亾dé卋堺 提交于 2019-12-24 01:55:25
问题 I have written an application that interfaces with the winspool print driver, and its been working just fine for months. I need to move my projects from .NET Framework 3.5 to 4.0 to include a coworkers assemblies, but doing this (and only doing this) causes one of my .dll imported method calls to fail when executing from the VS 2010 IDE. Both the debug and release binaries still work if I run them outside of the Visual Studio 2010 environment. Below is the line that now fails after moving to

Wrapping a c#/WPF GUI around c++/cli around native c++

纵饮孤独 提交于 2019-12-24 01:53:36
问题 This is kind of a complicated situation. I'm refactoring (ground-up) c++ that must be used as both a CGI script and the core of a standalone app. Unfortunately I haven't written C++ since college, and am more familiar with c#/Java. So I'm going to use WPF for the GUI. From what my research has revealed, this means that I will be: 1) Refactoring the base code in unmanaged C++ (yay for intellisense support, eh?) 2) Wrapping that base in a managed class library 3) Wrapping step 2 in a C#/WPF GUI

How to find first and last cell in ExcelInterop and graph range in C#

杀马特。学长 韩版系。学妹 提交于 2019-12-24 01:44:52
问题 Trying to graph a simple csv file in Excel : 1,2,3 4,5,6 7,8,9 How do I programmatically determine the graphing range to be A1:C3? I have tried var lastCell = worksheet.Cells.get_End(XlDirection.xlUp); to determine the final column but it doesn't seem to work. The following is the code that I am using to graph the file, and I just need to determine the range. using Microsoft.Office.InteropServices.Excel; Application application = new Application(); Workbook workbook = application.Workbooks

Multi instances COM object

。_饼干妹妹 提交于 2019-12-24 00:44:40
问题 I use a C++ written COM object in C#. I just create instance through "new". I need numerous of such objects. But every other "new" doesn't create new instance, but only gives reference on first object. Thats why I have a mess with data. Is it possible to get new instance every time? Or I should realize IClassFactory in my COM to instantiate not singleton? I've made COM with master in VC 2010 with ATL support. And I have a trouble where and how to realize IClassFactory. 回答1: You need to

IntPtr in 32 Bit OS, UInt64 in 64 bit OS

自闭症网瘾萝莉.ら 提交于 2019-12-24 00:24:24
问题 I'm trying to do an interop to a C++ structure from C#. The structure (in a C# wrapper) is something like this [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct SENSE4_CONTEXT { public System.IntPtr dwIndex; //or UInt64, depending on platform. } The underlying C++ structure is a bit abnormal. In 32 bit OS, dwIndex must be IntPtr in order for the interop to work, but in 64 bit OS, it must be UInt64 in order for the interop to work. Any idea how to modify the above

Why do global native objects cause problems in C++/CLI dlls?

徘徊边缘 提交于 2019-12-23 18:30:28
问题 I have read somewhere that it has something to do with non-simple global native objects that have constructors/destructors. Can someone explain what it is exactly that may cause trouble? 回答1: An Example: Once I tried to link a native C++ lib into a C++/CLI application. That lib contained a const static std::string . The application did always crash. Reason: When the application starts, it initializes the const static objects. To make sure that the static objects get deleted properly on

How to use SQLInstallDriverEx in C#?

那年仲夏 提交于 2019-12-23 17:48:03
问题 How would I rewrite the following function in order to use it in C# ? The function is part of odbccp32.dll and is used to install an ODBC driver . BOOL SQLInstallDriverEx( LPCSTR lpszDriver, LPCSTR lpszPathIn, LPSTR lpszPathOut, WORD cbPathOutMax, WORD * pcbPathOut, WORD fRequest, LPDWORD lpdwUsageCount); SQLInstallDriverEx Reference This is my attempt: [DllImport("odbccp32")] private static extern bool SQLInstallDriverEx( string lpszDriver, string lpszPathIn, out string lpszPathOut, ushort