interop

How to inject VBA code into Excel .xlsm without using Interop?

霸气de小男生 提交于 2019-11-27 14:11:38
问题 My goal is to add macros to an excel workbook without having to enable "Trust Access to the VBA Project Object Module" in the Excel Trust Center. (Enabling access seems a security risk). Found random pieces of puzzle on my initial fact finding search: -I see that VBA script is stored in the zipped .xlsm file as vbaProject.bin. -There are several free/commercial resources that can work with excel files: Create excel without interop and template with or without row and columnspan It would be

Excel Process not closing in VB.net

笑着哭i 提交于 2019-11-27 14:10:49
I am creating an excel file using interop.excel and the process is not closing. This is the code i am trying to use. Private Sub converToExcel(fileLoc As String, ds As DataSet) Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkBooks As Excel.Workbooks Dim xlWorkSheet As Excel.Worksheet Dim misValue As Object = System.Reflection.Missing.Value Dim i As Integer Dim j As Integer xlApp = New Excel.Application xlWorkBooks = xlApp.Workbooks xlWorkBook = xlWorkBooks.Add(misValue) xlWorkSheet = xlWorkBook.Sheets("sheet1") For i = 0 To ds.Tables(0).Rows.Count - 1 For j = 0 To ds

Registering COM referenced DLLs on a build server

与世无争的帅哥 提交于 2019-11-27 14:08:43
问题 We're developing a C# application that references a few COM libraries (AutoIT for example). I am including all referenced components under source control, in a 3rd party "Libs" folder. The problem is that COM dll's don't have a HintPath property in the .csproj file, and i assume these must be manually registered using regsvr32 (or using a script of some sort). I am currently looking into creating an MSBuild script that will run before every build, however i couldn't figure out if i should be

Entry Point Not Found Exception

允我心安 提交于 2019-11-27 13:54:10
问题 I'm trying to use a C++ unmanaged dll in a C# project and I'm getting an error when trying to call a function that says that entry point cannot be found. public class Program { static void Main(string[] args) { IntPtr testIntPtr = aaeonAPIOpen(0); Console.WriteLine(testIntPtr.ToString()); } [DllImport("aonAPI.dll")] public static extern unsafe IntPtr aaeonAPIOpen(uint reserved); } Here is the dumpbin for the function: 5 4 00001020 ?aaeonAPIOpen@@YAPAXK@Z I changed the dll import to [DllImport

Could not load file or assembly 'Microsoft.mshtml … Strong name validation failed

依然范特西╮ 提交于 2019-11-27 13:46:04
问题 I made a WPF/C# program and I am using the internet control for WYSIWYG HTML editing. it is a regular Executable program. it works on most computers however some computers are giving me the following error. Could not load file or assembly 'Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Strong name validation failed. The 'Microsoft.mshtml.dll' file is distributed with the program. It is with all of the other required dlls in

Cneonction and nnCoection HTTP headers

瘦欲@ 提交于 2019-11-27 13:44:24
问题 We have often some issues in terms of interoperability on the Web. One of these issues for browsers vendors is the wrongly spelled Connection HTTP header. The most common errors are given by these two forms. nnCoection: Cneonction: There are has been a few articles about this, including Fun with HTTP headers. Often it is happening by period, then disappear. It seems that some of them are created by load balancers such as this example: NetScaler Appliance. Do you know any other instances of

Java and C# interoperability

拜拜、爱过 提交于 2019-11-27 13:33:07
问题 I have two programs. One is in C# and another one in Java. Those programs will, most probably, always run on the same machine. What would be the best way to let them talk to each other? So, to clarify the problem: This is a personal project (so professional/costly libraries are a no go). The message volume is low, there will be about 1 to 2 messages per second. The messages are small, a few primitive types should do the trick. I would like to keep the complexity low. The java application is

SetText of textbox in external app. Win32 API

ⅰ亾dé卋堺 提交于 2019-11-27 13:22:56
Using Winspector I've found out the ID of the child textbox I want to change is 114. Why isn't this code changing the text of the TextBox? [DllImport("user32.dll")] static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem); [DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int msg, int Param, string s); const int WM_SETTEXT = 0x000c; private void SetTextt(IntPtr hWnd, string text) { IntPtr boxHwnd = GetDlgItem(hWnd, 114); SendMessage(boxHwnd, WM_SETTEXT, 0, text); } The following is what I've used successfully for that purpose w/ my GetLastError error checking

WinForms Interop, Drag & Drop from WinForms -> WPF

拜拜、爱过 提交于 2019-11-27 13:13:34
问题 I'm trying to drag data from the Winforms portion of my application on a WPF controls that's contained inside an "ElementHost". And it crashes when I try doing so. Trying the same thing but from Winforms to Winforms works fine. (See example code below) I need help on making this work... have any clues what I'm doing wrong? Thanks! Example: In the sample code below, I'm just trying to drag a custom MyContainerClass object created when initating the drag on the label control on a 1) System

Passing a vector/array from unmanaged C++ to C#

百般思念 提交于 2019-11-27 12:53:43
I want to pass around 100 - 10,000 Points from an unmanaged C++ to C#. The C++ side looks like this: __declspec(dllexport) void detect_targets( char * , int , /* More arguments */ ) { std::vector<double> id_x_y_z; // Now what's the best way to pass this vector to C# } Now my C# side looks like this: using System; using System.Runtime.InteropServices; class HelloCpp { [DllImport("detector.dll")] public static unsafe extern void detect_targets( string fn , /* More arguments */ ); static void Main() { detect_targets("test.png" , /* More arguments */ ); } } How do I need to alter my code in order