Search Results

Search found 800 results on 32 pages for 'interop'.

Page 3/32 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Outlook Interop: Password protected PST file headache

    - by Ed Manet
    Okay, I have no problem identifying the .PST file using the Outlook Interop assemblies in a C# app. But as soon as I hit a password protected file, I am prompted for a password. We are in the process of disabling the use of PSTs in our organization and one of the steps is to unload the PST files from the users' Outlook profile. I need to have this app run silently and not prompt the user. Any ideas? Is there a way to create the Outlook.Application object with no UI and then just try to catch an Exception on password protected files? // create the app and namespace Application olApp = new Application(); NameSpace olMAPI = olApp.GetNamespace("MAPI"); // get the storeID of the default inbox string rootStoreID = olMAPI.GetDefaultFolder(OlDefaultFolders.olFolderInbox).StoreID; // loop thru each of the folders foreach (MAPIFolder fo in olMAPI.Folders) { // compare the first 75 chars of the storeid // to prevent removing the Inbox folder. string s1 = rootStoreID.Substring(1, 75); string s2 = fo.StoreID.Substring(1, 75); if (s1 != s2) { // unload the folder olMAPI.RemoveStore(fo); } } olApp.Quit();

    Read the article

  • Some languages don't work when using Word 2007 Spellcheck from Interop

    - by Tridus
    I'm using the Word 2007 spellchecker via Interop in a VB.net desktop app. When using the default language (English), it works fine. If I set the language to French via LanguageId, it also works. But if I set it to French (Canadian) (Word.WdLanguageID.wdFrenchCanadian), it doesn't work. There's no error message, it simply runs and says the document contains no errors. I know it does, if I paste the exact same text into Word itself and run it with the French (Canadian) dictionary, it finds errors. Just why that dictionary doesn't work is kind of a mystery to me. Full code below: Public Shared Function SpellCheck(ByVal text As String, ByVal checkGrammar As Boolean) As String ' If there is no data to spell check, then exit sub here. If text.Length = 0 Then Return text End If Dim objWord As Word.Application Dim objTempDoc As Word.Document ' Declare an IDataObject to hold the data returned from the ' clipboard. Dim iData As IDataObject objWord = New Word.Application() objTempDoc = objWord.Documents.Add objWord.Visible = False ' Position Word off the screen...this keeps Word invisible ' throughout. objWord.WindowState = 0 objWord.Top = -3000 ' Copy the contents of the textbox to the clipboard Clipboard.SetDataObject(text) ' With the temporary document, perform either a spell check or a ' complete ' grammar check, based on user selection. With objTempDoc .Content.Paste() .Activate() .Content.LanguageID = Word.WdLanguageID.wdFrenchCanadian If checkGrammar Then .CheckGrammar() Else .CheckSpelling() End If ' After user has made changes, use the clipboard to ' transfer the contents back to the text box .Content.Copy() iData = Clipboard.GetDataObject If iData.GetDataPresent(DataFormats.Text) Then text = CType(iData.GetData(DataFormats.Text), _ String) End If .Saved = True .Close() End With objWord.Quit() Return text End Function

    Read the article

  • C# Interop.Word Adding an Image from project resource folder

    - by iamnobody
    Hi guys. Having some image problem with Interop.Word and C#. I want to add an image in the header of the document that I am going to generate. I have this code working perfectly section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Shapes.AddPicture(@"C:\Logo.jpg", ref x, ref x, ref x, ref x, ref x, ref x, ref x); Problem is that I can't have "C:\Logo.jpg" in the code since after publishing the project, there would most probably be no Logo.jpg in the C folder of the user. The image is already in my project's resource folder. I've used Image.FromFile("Logo.jpg") before but .AddPicture requires a string and not an image. Any ideas? Any help would be greatly appreciated. Thanks! -- edit -- Saw this over the net: string anyPath = @"C:\logo.jpg"; Properties.Resources.logo.Save(anyPath); section.Headers.[...].Shapes.AddPicture(anyPath, ... but then I still get a generic error in GDI+ or ExternalException was unhandled.

    Read the article

  • Bullet indents in PowerPoint 2007 compatibility mode via .NET interop issue

    - by L. Shaydariv
    Hello. I've got a really difficult bug and I can't see the fix. The subject drives me insane for real for a long time. Let's consider the following scenario: 1) There is a PowerPoint 2003 presentation. It contains the only slide and the only shape, but the shape contains a text frame including a bulleted list with a random textual representation structure. 2) There is a requirement to get bullet indents for every bulletted paragraph using PowerPoint 2007. I can satisfy the requirement opening the presentation in the compatibility mode and applying the following VBA script: With ActivePresentation Dim sl As Slide: Set sl = .Slides(1) Dim sh As Shape: Set sh = sl.Shapes(1) Dim i As Integer For i = 1 To sh.TextFrame.TextRange.Paragraphs.Count Dim para As TextRange: Set para = sh.TextFrame.TextRange.Paragraphs(i, 1) Debug.Print para.Text; para.indentLevel, sh.TextFrame.Ruler.Levels(para.indentLevel).FirstMargin Next i End With that produces the following output: A 1 0 B 1 0 C 2 24 D 3 60 E 5 132 Obviously, everything is perfect indeed: it has shown the proper list item text, list item level and its bullet indent. But I can't see the way of how I can reach the same result using C#. Let's add a COM-reference to Microsoft.Office.Interop.PowerPoint 2.9.0.0 (taken from MSPPT.OLB, MS Office 12): // presentation = ...("presentation.ppt")... // a PowerPoint 2003 presentation Slide slide = presentation.Slides[1]; Shape shape = slide.Shapes[1]; for (int i = 1; i<=shape.TextFrame.TextRange.Paragraphs(-1, -1).Count; i++) { TextRange paragraph = shape.TextFrame.TextRange.Paragraphs(i, 1); Console.WriteLine("{0} {1} {2}", paragraph.Text, paragraph.IndentLevel, shape.TextFrame.Ruler.Levels[paragraph.IndentLevel].FirstMargin); } Oh, man... What's it? I've got problems here. First, the paragraph.Text value is trimmed until the '\r' character is found (however paragraph.Text[0] really returns the first character O_o). But it's ok, I can shut my eyes to this. But... But, second, I can't understand why the first margins are always zero and it does not matter which level they belong to. They are always zero in the compatibility mode... It's hard to believe it... :) So is there any way to fix it or just to find a workaround? I'd like to accept any help regarding to the solution of the subject. I can't even find any article related to the issue. :( Probably you have ever been face to face with it... Or is it just a bug with no fix and must it be reported to Microsoft? Thanks you.

    Read the article

  • Not able to instantiate PDF browser control from AcroPDF.dll using COM and .NET interop

    - by knut
    When I try to instantiate a PDF browser control like this in C#: AcroPDFLib.AcroPDFClass acrobat = new AcroPDFLib.AcroPDFClass(); I get a COMException with this message: Creating an instance of the COM component with CLSID {CA8A9780-280D-11CF-A24D-444553540000} from the IClassFactory failed due to the following error: 80004005. I have made a reference to AcroPDF.dll which has the component name Adobe Acrobat 7.0 Browser Control Type Library 1.0. I can't figure out what is wrong. Help most appreciated!

    Read the article

  • COM Interop without regasm

    - by SLaks
    I'm a limited user, and I need to write an Outlook macro that exposes a C# library in Outlook 2003 and 2007. I do not have any admin privilges at all, not even at install time, so I can't run RegAsm and I can't (I assume) write a managed add-in. Is there any way to call .Net code from VBA in this scenario, or are there any other solutions? This is for personal use only, so an ugly hack is perfectly acceptable (so long as it works)

    Read the article

  • Encrypting using RSA via COM Interop = "The requested operation requires delegation to be enabled on

    - by Mr AH
    Hi Guys, So i've got this little static method in a .Net class which takes a string, uses some stored public key and returns the encrypted version of that key. This is basically so some user entered data can be saved an encrypted, then retrieved and decrypted at a later date. Pretty basic stuff and the unit test works fine. However, part of the application is in classic ASP. This then uses some COM visible version of the class to go off and invoke the method on the real class and return the same string to the COM client (classic ASP). I use this kind of stuff all the time, but in this case we have a major problem. As the method is doing something with RSA keys and has to access certain machine information to do so, we get the error: "The requested operation requires delegation to be enabled on the machine. I've searched around a lot, but can't really understand what this means. I assume I am getting this error on the COM but not the UT because the UT runs as me (Administrator) and classic ASP as IWAM. Anyone know what I need to do to enable IWAM to do this? Or indeed if this is the real problem here?

    Read the article

  • COM Interop error, class not registered when using MSMQ Library

    - by mattmck
    I've referenced the MSMQ v3 Object Library in a VS2010 C# project only to get: System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {0188401C-247A-4FED-99C6-BF14119D7055} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). I've registered the library the reference points to: regsvr32 C:\windows\system32\mqoa.dll What am I missing? Assuming this works, what will I have to do at deployment to ensure the app will run on other machines with MSMQ installed?

    Read the article

  • Worksheet.Unprotect - Office Interop - Difference between 2003 and 2007

    - by sdmcnitt
    I have a .NET winforms app that automates Excel and checks for a worksheet password. The requirements are to be able to detect 1) that the protection is turned off 2) that the password is removed (protected but there is no password) 3) that the password matches the correct password from a database To meet the second requirement the program calls the Worksheet.Unprotect command with a null string, capturing the error. If error as expected, the 3rd check is made. If no error, then the Unprotect worked without a password == password was removed. The code sample below has these checks. The application can do this fine with Office 2003. I have since had my dev machine updated to Office 2007 and it no longer works as it did. When I call the Worksheet.Unprotect, Excel prompts for the password! I need to know how this should be accomplished in the new version of Excel or if there is a way to reference the old PIA. No matter what if I set a reference to Excel 11 it is replaced with the PIA for 12 in the GAC. 'return true if unprotect of worksheet does not generate an error 'all other errors will bubble up 'return false if specific error is "Password is invalid..." Try 'detect unprotected or no password If oWorksheet.ProtectContents Then 'try with no passsword and expect an error 'if no error then raise exception Dim blnRaiseException As Boolean = True Try 'oWorksheet.Unprotect(vbNullString) oWorksheet.Unprotect() Catch ex As Exception blnRaiseException = False End Try If blnRaiseException Then Throw New ExcelSheetNoPasswordException End If oWorksheet.Unprotect(strPwd) 'no error so if we get here -- success fnCheckWorksheetPwd = True 'leave as it was -- this may still cause workbook to think it is changed oWorksheet.Protect(strPwd) Else Throw New ExcelSheetNotProtectedException End If Catch COMex As System.Runtime.InteropServices.COMException 'handle error code -2146827284 If COMex.ErrorCode = -2146827284 Then 'this is the error we're looking for Else Throw End If Catch ex As Exception Throw End Try

    Read the article

  • import txt files using excel interop in C# (QueryTables.Add)

    - by kite
    Hi all, I am trying to insert text files into excel cell using Querytables.Add; no error, but the worksheet is empty. except for the single cell manipulation using Value2 property. I already using macro to record the object used. Can you help me on this(I am using vs2008, C# , excel 2003 and 2007; both shown empty cell). Below is my code; thanks for your help Application application = new ApplicationClass(); try { object misValue = Missing.Value; wbDoc = application.Workbooks.Open(flnmDoc, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue); wsRefDocBudgetOwner = (Worksheet)wbDoc.Worksheets[2]; Range lRange = wsRefDocBudgetOwner.get_Range("B2", "B25"); var temp2 = wsRefDocBudgetOwner.QueryTables; var temp = temp2.Add(@"TEXT;d:\temp\config ssas.txt", lRange, Type.Missing); //temp.RefreshStyle = XlCellInsertionMode.xlInsertDeleteCells; //temp.RefreshOnFileOpen = true; wsRefDocBudgetOwner.get_Range("B1", "B1").Value2 = "Lgfdgast adsffdafadfads"; wbDoc.Save(); //wbDoc.SaveAs(flnmDoc2, misValue, misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, // misValue, misValue, misValue, misValue, misValue); wbDoc.Close(Missing.Value, Missing.Value, Missing.Value); } finally { application.Quit(); }

    Read the article

  • IIS, Impersonation and COM Interop Premission Denied

    - by user315690
    Hello we are in the throws of integrating a Document Management System with Dynamic CRM 4, have done similar things previously but in this instance we are having to reference a COM dll. We've configured the asp.net page (we are bringing the info in via a i-Frame in CRM), setting Impersonation = True in the Webconfig and ensured that Windows authentication is the only method available within IIS. All works as we would expect when logged into the server itself and the page happily does off finds all the relevant documents for the CRM account and presents them to a user in a nice Infragistics CRM styled grid. However trying this from a client workstation we get the following: System.Runtime.InteropServices.COMException (0xC0042335): Permission denied. Impersonation appears to be passing over the correct details but nothing we've tried thus far has been able to make this work outside of logging into the server. Any thoughts as to what we are missing?

    Read the article

  • Issue with Silverlight interop with JBoss WebService

    - by Hadi Eskandari
    I have a simple JAXWS webservice deployed in JBoss. It runs fine with a java client but I'm trying to connect using a Silverlight 3.0 application. I've changed the webservice to use Soap 1.1: @BindingType(value = "http://schemas.xmlsoap.org/wsdl/soap/http") public class UserSessionBean implements UserSessionRemote { ... } I'm using BasicHttpBinding on the Silverlight client. There are two issues: 1- When I connect from VisualStudio (2008 and 2010) to create the webservice proxies, the following exception is thrown, but the proxy is generated successfully. This also happens when I try to update the existing web service reference (but it also updates fine). com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: application/soap+xml; charset=utf-8 Supported ones are: [text/xml] at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:291) at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:128) at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:287) at com.sun.xml.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:276) at com.sun.xml.ws.transport.http.HttpAdapter.access$500(HttpAdapter.java:93) at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:432) at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244) at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135) at org.jboss.wsf.stack.metro.RequestHandlerImpl.doPost(RequestHandlerImpl.java:225) at org.jboss.wsf.stack.metro.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:82) at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) at java.lang.Thread.run(Thread.java:619) 2- When I use the proxy to fetch some data from the webservice (even methods with primitive types), I get the following error on Silverlight client: "An error occurred while trying to make a request to URI 'http://localhost:9090/admintool/UserSessionEJB'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details." Setting a breakpoint on my java code, I can see that it is not hit when I run the silverlight client, so it is probably a cross domain issue, but I'm not sure how to handle it (I've already created a crossdomain.xml file and put it beside my HTML page hosting the silverlight client). I appreciate any help!

    Read the article

  • Error when instantiating .NET/COM interop class via classic ASP

    - by Lee D
    Hi all, I am having a problem when trying to instantiate a C# .NET class that's been exposed to COM in a classic ASP application. I've used tlbexp to generate a typelib and registered it in Component Services; now when trying to create the object as such: Server.CreateObject("The.Class.Name") I am getting the error: Server object error 'ASP 0177 : 80131534' Server.CreateObject Failed I've searched around online for information on this error, and found numerous discussions but no solution. The error code 0x80131534 apparently means "COR_E_TYPEINITIALIZATION, a type failed to initialize", which would suggest the problem would be in the constructor. The constructor of the class in question sets a private field to an instance of another class from the same assembly, and then reads some configuration settings from an XML file. This behaviour is unit tested and I've checked that the file exists; I can't see anything else that could be breaking in there. A few other points which may or may not be of use: A test .NET project referencing the DLL can instantiate the class just fine; however a test VB6 project referencing the TLB blows up with the same error. Both the DLL and the TLB are in the same location. This application is running locally, on Windows XP Professional SP3 and IIS 5.1. The .NET assembly is built with .NET Framework 2.0, although 3.5 is installed on the machine. I know other people who don't get this error on their builds, so I believe it may be something environmental. Any suggestions are welcome as I've been struggling to fix this for some time. Thanks in advance.

    Read the article

  • Mono vs .NET Interop curiosity

    - by Olaseni
    I'm developing a huge console application for Unix using C# via Mono. If I develop that app using M Visual Studio and .NET 3.5 and I carefully neglect to use win32 specific API calls, should I expect that application to automatically work in my Unix box? Or should I just get MonoDevelop and go the Mono way?

    Read the article

  • How can we expose a .NET public const to COM interop

    - by JulienC
    For historical reasons, we need to expose string constants in .NET through COM interface. We managed to expose ENUM but we can't find a way to expose string const. We try the following code : <ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _ Public Class ComClass1 #Region "COM GUIDs" ' These GUIDs provide the COM identity for this class ' and its COM interfaces. If you change them, existing ' clients will no longer be able to access the class. Public Const ClassId As String = "608c6545-977e-4260-a3cf-11545c82906a" Public Const InterfaceId As String = "12b8a6c7-e7f6-4022-becd-2efd8b3a756e" Public Const EventsId As String = "05a2856f-d877-4673-8ea8-20f5a9f268d5" #End Region ' A creatable COM class must have a Public Sub New() ' with no parameters, otherwise, the class will not be ' registered in the COM registry and cannot be created ' via CreateObject. Public Sub New() MyBase.New() End Sub Public Const chaine As String = "TEST" Public Sub Method() End Sub End Class But when we look on the OLE object viewer, we only see the method. See ScreenShot: screenshot of OLE viewer Anyone have an idea ? Thanks,

    Read the article

  • .NET interop COM DLL behaves differently in VB6 debugger

    - by Aheho
    I have a .NET v2.0 Dll that exposes a few classes to COM. The assembly is called BLogic.DLL I'm calling these classes from a legacy visual basic 6.0 application. I can generate and EXE file and if I have Blogic.dll in the same folder as the EXE, the program runs without a hitch. However If I try and launch the same program within the VB6 debugger I get a: Automation Error The system cannot find the file specified I assume when I'm running in the debugger, the PLogic.dll file can't be found. I tried putting it in the System32 folder, and the same folder as the VB6.EXE file, but I still get the same error. Other facts that may help: PLogic.dll is NOT a strongly-named assembly. It depends on a 3rd party reference that isn't strongly signed so VS doesn't let me strongly sign it. However the 3rd party functionality isn't being called by the VB6 code, and it is not ComVisible.

    Read the article

  • How to dispose of a NET COM interop object on Release()

    - by mhenry1384
    I have a COM object written in managed code (C++/CLI). I am using that object in standard C++. How do I force my COM object's destructor to be called immediately when the COM object is released? If that's not possible, call I have Release() call a MyDispose() method on my COM object? My code to declare the object (C++/CLI): [Guid("57ED5388-blahblah")] [InterfaceType(ComInterfaceType::InterfaceIsIDispatch)] [ComVisible(true)] public interface class IFoo { void Doit(); }; [Guid("417E5293-blahblah")] [ClassInterface(ClassInterfaceType::None)] [ComVisible(true)] public ref class Foo : IFoo { public: void MyDispose(); ~Foo() {MyDispose();} // This is never called !Foo() {MyDispose();} // This is called by the garbage collector. virtual ULONG Release() {MyDispose();} // This is never called virtual void Doit(); }; My code to use the object (native C++): #import "..\\Debug\\Foo.tlb" ... Bar::IFoo setup(__uuidof(Bar::Foo)); // This object comes from the .tlb. setup.Doit(); setup-Release(); // explicit release, not really necessary since Bar::IFoo's destructor will call Release(). If I put a destructor method on my COM object, it is never called. If I put a finalizer method, it is called when the garbage collector gets around to it. If I explicitly call my Release() override it is never called. I would really like it so that when my native Bar::IFoo object goes out of scope it automatically calls my .NET object's dispose code. I would think I could do it by overriding the Release(), and if the object count = 0 then call MyDispose(). But apparently I'm not overriding Release() correctly because my Release() method is never called. Obviously, I can make this happen by putting my MyDispose() method in the interface and requiring the people using my object to call MyDispose() before Release(), but it would be slicker if Release() just cleaned up the object. Is it possible to force the .NET COM object's destructor, or some other method, to be called immediately when a COM object is released? Googling on this issue gets me a lot of hits telling me to call System.Runtime.InteropServices.Marshal.ReleaseComObject(), but of course, that's how you tell .NET to release a COM object. I want COM Release() to Dispose of a .NET object.

    Read the article

  • c# interop with ghostscript

    - by yodaj007
    I'm trying to access some Ghostscript functions like so: [DllImport(@"C:\Program Files\GPLGS\gsdll32.dll", EntryPoint = "gsapi_revision")] public static extern int Foo(gsapi_revision_t x, int len); public struct gsapi_revision_t { [MarshalAs(UnmanagedType.LPTStr)] string product; [MarshalAs(UnmanagedType.LPTStr)] string copyright; long revision; long revisiondate; } public static void Main() { gsapi_revision_t foo = new gsapi_revision_t(); Foo(foo, Marshal.SizeOf(foo)); This corresponds with these definitions from the iapi.h header from ghostscript: typedef struct gsapi_revision_s { const char *product; const char *copyright; long revision; long revisiondate; } gsapi_revision_t; GSDLLEXPORT int GSDLLAPI gsapi_revision(gsapi_revision_t *pr, int len); But my code is reading nothing into the string fields. If I add 'ref' to the function, it reads gibberish. However, the following code reads in the data just fine: public struct gsapi_revision_t { IntPtr product; IntPtr copyright; long revision; long revisiondate; } public static void Main() { gsapi_revision_t foo = new gsapi_revision_t(); IntPtr x = Marshal.AllocHGlobal(20); for (int i = 0; i < 20; i++) Marshal.WriteInt32(x, i, 0); int result = Foo(x, 20); IntPtr productNamePtr = Marshal.ReadIntPtr(x); IntPtr copyrightPtr = Marshal.ReadIntPtr(x, 4); long revision = Marshal.ReadInt64(x, 8); long revisionDate = Marshal.ReadInt64(x, 12); byte[] dest = new byte[1000]; Marshal.Copy(productNamePtr, dest, 0, 1000); string name = Read(productNamePtr); string copyright = Read(copyrightPtr); } public static string Read(IntPtr p) { List<byte> bits = new List<byte>(); int i = 0; while (true) { byte b = Marshal.ReadByte(new IntPtr(p.ToInt64() + i)); if (b == 0) break; bits.Add(b); i++; } return Encoding.ASCII.GetString(bits.ToArray()); } So what am I doing wrong with marshaling?

    Read the article

  • WCF service and COM interop callback

    - by Sjblack
    I have a COM object that creates an instance of a WCF service and passes a handle to itself as a callback. The com object is marked/initialized as MTA. The problem being every instance of the WCF service that makes a call to the callback occurs on the same thread so they are being processed one at a time which is causing session timeouts under a heavy load. The WCF service is session based not sure if that makes any difference.

    Read the article

  • Interop: HmacSHA1 in Java and dotNet

    - by wilth
    Hello, In an app we are calculating a SHA1Hmac in java using the following: SecretKey key = new SecretKeySpec(secret, "HmacSHA1"); Mac m = Mac.getInstance("HmacSHA1"); m.init(secret); byte[] hmac = m.doFinal(data); And later, the hmac is verified in C# - on a SmartCard - using: HMACSHA1 hmacSha = new HMACSHA1(secret); hmacSha.Initialize(); byte[] hmac = hmacSha.ComputeHash(data); However, the result is not the same. Did I overlook something important? The inputs seem to be the same. Here some sample inputs: Data: 546573746461746131323341fa3c35 Key: 6d795472616e73616374696f6e536563726574 Result Java: 37dbde318b5e88acbd846775e38b08fe4d15dac6 Result C#: dd626b0be6ae78b09352a0e39f4d0e30bb3f8eb9 I wouldn't mind to implement my own hmacsha1 on both platforms, but using what already exists.... Thanks!

    Read the article

  • C++/CLI com-Interop: Exposing a reference type property to VBA

    - by Adam
    After long hours of investigation on exposing C# property that accepts a reference type to VBA, I concluded that it was not possible. In brief, a C# property that is of type double[] or even an object cannot be consumed in VBA like this: ' Compile Error: Function or interface marked as restricted, ' or the function uses an Automation type not supported in Visual Basic oComExposedEarlyBinding.ObjectArray = VBArray ' Run-time error 424: Object required oComExposedEarlyBinding.PlainObject = VBArray Or for more details: C# property exposed to VBA (COM) : Run-time error '424': Object required I would like to know if C++/CLI would support such an option? i.e. Allowing a reference-type property to be exposed to VBA so that a syntax like the above is valid. N.B. You can achieve this by using late binding, but losing the intellisense is not an option.

    Read the article

  • Static nested class visibility issue with Scala / Java interop

    - by Matt R
    Suppose I have the following Java file in a library: package test; public abstract class AbstractFoo { protected static class FooHelper { public FooHelper() {} } } I would like to extend it from Scala: package test2 import test.AbstractFoo class Foo extends AbstractFoo { new AbstractFoo.FooHelper() } I get an error, "class FooHelper cannot be accessed in object test.AbstractFoo". (I'm using a Scala 2.8 nightly). The following Java compiles correctly: package test2; import test.AbstractFoo; public class Foo2 extends AbstractFoo { { new FooHelper(); } } The Scala version also compiles if it's placed in the test package. Is there another way to get it to compile?

    Read the article

  • C# / IronPython Interop with shared C# Class Library

    - by Adam Haile
    I'm trying to use IronPython as an intermediary between a C# GUI and some C# libraries, so that it can be scripted post compile time. I have a Class library DLL that is used by both the GUI and the python and is something along the lines of this: namespace MyLib { public class MyClass { public string Name { get; set; } public MyClass(string name) { this.Name = name; } } } The IronPython code is as follows: import clr clr.AddReferenceToFile(r"MyLib.dll") from MyLib import MyClass ReturnObject = MyClass("Test") Then, in C# I would call it as follows: ScriptEngine engine = Python.CreateEngine(); ScriptScope scope = null; scope = engine.CreateScope(); ScriptSource source = engine.CreateScriptSourceFromFile("Script.py"); source.Execute(scope); MyClass mc = scope.GetVariable<MyClass>("ReturnObject ") When I call this last bit of code, source.Execute(scope) runs returns successfully, but when I try the GetVariable call, it throw the following exception Microsoft.Scripting.ArgumentTypeException: expected MyClass , got MyClass So, you can see that the class names are exactly the same, but for some reason it thinks they are different. The DLL is in a different directory than the .py file (I just didn't bother to write out all the path setup stuff), could it be that there is an issue with the interpreter for IronPython seeing these objects as difference because it's somehow seeing them as being in a different context or scope?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >