.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Sharon Maxwell
Post New Web Links

Can't call C# object via a COM interface, because its not wrapped by RCW after GetObjectForIUnknown

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :.NET Framework
 

I am using some code to try and get a handle to the OLE IDropTarget COM interface implementation for a WPF Window, so that I can call interface methods directly. What I expected is that the object is returned as a COM callable runtime wrapper object, and that I could cast it to my own declaration of the IDropTarget interface, see code below:

 

 

Window w = Window.GetW


View Complete Post


More Related Resource Links

Get xhr object in vb.net when error occured in ajax call using JQuery.

  
Hi Dude,   I have a big problem in Jquery ajax call. I am calling the web service whenever click the update button. I have a separate web service class, in which consist of few methods. When I calling the web service method, I have made the error handling and log the error information in db after that I have to override the "ex" that means error object to XMLHttpRequest. Is it possible to assign the sqlexception to ajax object (xhr) in vb.net? Please help me its much more useful for me.   Thank in advance.

Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset'

  
I'm repairing a custom cube being fed off a Dynamics AX 2009 instance. This particular named query looks like this: SELECT CUSTTABLE.ACCOUNTNUM, CUSTTABLE.CASHDISC, CUSTTABLE.SHIPCARRIERBLINDSHIPMENT, CUSTTABLE.PARTYTYPE, CUSTTABLE.PARTYID, CUSTTABLE.SHIPCARRIERACCOUNTCODE, CUSTTABLE.PROJPRICEGROUP, CUSTTABLE.SYNCENTITYID, CUSTTABLE.SYNCVERSION, CUSTTABLE.MEMO, CUSTTABLE.SALESDISTRICTID, CUSTTABLE.CURRENCY, CUSTTABLE.SEGMENTID, CUSTTABLE.SUBSEGMENTID, CUSTTABLE.COMPANYCHAINID, CUSTTABLE.MAINCONTACTID, CUSTTABLE.IDENTIFICATIONNUMBER, CUSTTABLE.PARTYCOUNTRY, CUSTTABLE.PARTYSTATE, CUSTTABLE.SALESGROUP, CUSTTABLE.BLOCKED, CUSTTABLE.ONETIMECUSTOMER, CUSTTABLE.ACCOUNTSTATEMENT, CUSTTABLE.CREDITMAX, CUSTTABLE.MANDATORYCREDITLIMIT, CUSTTABLE.DIMENSION, CUSTTABLE.DIMENSION2_, CUSTTABLE.DIMENSION3_, CUSTTABLE.NAME, CUSTTABLE.VENDACCOUNT, CUSTTABLE.TELEX, CUSTTABLE.PRICEGROUP, CUSTTABLE.MULTILINEDISC, CUSTTABLE.ENDDISC, CUSTTABLE.VATNUM, CUSTTABLE.COUNTRYREGIONID, CUSTTABLE.INVENTLOCATION, CUSTTABLE.DLVTERM, CUSTTABLE.DLVMODE, CUSTTABLE.ADDRESS, CUSTTABLE.MARKUPGROUP, CUSTTABLE.MBSFIRSTNAME, CUSTTABLE.MBSLASTNAME, CUSTTABLE.MBSMESSAGETEXT, CUSTTABLE.MBSNOBOALLOWED, CUSTTABLE.MBSCOLLECTORCODE, CUSTTABLE.MBSDLVROUTESEQ, CUSTTABLE.MBSBOALLOCATIONPRIORITY, CUSTTABLE.MBSCUSTEMOTION, CUSTTABLE.MBSPRICEFLOOR, CUSTTABLE.MBSPRICECEILING, CU

Is it possible to cast COM object to the custom interface?

  

I have following code which succesfully works using some COM wrapper library with all needed managed types for COM objects

mshtml.HTMLDocumentClass doc = (mshtml.HTMLDocumentClass)_webBrowser.Document;

mshtml.HTMLIFrameClass iframe = (doc).getElementById("SomeFrameName") as mshtml.HTMLIFrameClass;

if (string.Equals(iframe.readyState.ToString(), "complete", StringComparison.OrdinalIgnoreCase))

{

 // Do something

}

But I need to avoid this COM wrapper Micrososft.mshtml.dll and use custom interfaces for this reason, so please explain me how way can I work with COM objects with custom interfaces? How do I write them and avoid classes mshtml.HTMLDocumentClass and mshtml.HTMLIFrameClass?

Create an exchange interface to call a Windows Service with WCF

  
Hi!

I'm develpong an application that consists on a Client that communicates with a Windows Service via WCF.
I have three projects defined: MyClient, MyService, MyExchangeClasses

The first two are easy to understand, client and server. The MyExchangeClasses project contains the interface for MyService remote function calls and contains the implementation of those classes that are passed via parameter o are returned by the remote functions that implement the interface I've already mentioned.

For example I have one remote funciton defined in the interface like this:


[ServiceContract]
public interface IService1
{
   [OperationContract]
   IEnumerable<MyObject> GetAllMyObjects();
}




And MyObject is defined like this:



[DataContract]
public class MyObject    
{
    [DataMember]
    public String Name { get; set; }
}


So in order to make it work MyExchangeClasses needs to be referenced in both MyClient and MyService classes.

Interface object Versus Class Object

  

Asslam o Alaikum

namespace Interface
{
    interface IMyInterface
    {
        void Start();    
        void Stop();
    }

    class Program : IMyInterface
    {
        void IMyInterface.Start()
        {
            Console.WriteLine("\n Void Start Method Implement");
        }
        void IMyInterface.Stop()
        {
            Console.WriteLine("\n Void Stop Method Implement");
        }
        
        static void Main(string[] args)
        {
            IMyInterface iMyInterface = new Program();
            iMyInterface.Start();
            iMyInterface.Stop();
        }
    }
}


1. IMyInterface iMyInterface = new IMyInterface(); // if i create the object of interface i get Error
2. Program iMyInterface = new Program(); // if i create the object of program i can't get the property of Interfaces i.e. Start(); stop();
3. IMyInterface iMyInterface = new Program(); // This will work fine

i want know the difference about 3 points can any body claer it ..

Thanks


resolving type information of webmethod object parameters from non .NET client call

  

Hi,

I have a asmx web service that has exposed my Product and Order object.


I've a non .NET client that builds their own Product and Order classes using SOAP libraries.


Now, in my web serivce, i've a web method SaveEntity(object[] entities) where the entities array holds Product or Order or both objects it receives from non .NET client. 


Now, I need to extract the type information for each of the entities inside the object[] array. The first choice is object.GetType(). But my question is: is it guaranteed that object.GetType would return the exact type information (Product or Order for this instance)? 


Thanks in advance


how to make VS Intellisense show complex object's properties for result of Ajax call?

  

Hello,

I've create a WCF webservice and created a proxy to the service using ScriptManager.

I can see the created a proxy class, and intellisense pops up the methods of the webservice (great!!). But, I can't see the properties of the method params, return types.

The webservice method:

searchResponse DBSearch.Search(searchRequest)

have comlex types as a parameter (searchRequest) and a return type (searchResponse).

Intellisense does recognize these types, but I can not see the properties (javacript does);

i.e.

var _searchRequest = new DBSearch.SearchRequest; (intellisense knows type SearchRequest)

_searchRequest.query = "liver lacerations"; (intellisense doesn't know it's property 'query')

_searchRequest.searchOptions = "modality=mri";


Obviously, with javascript, var _searchRequest is not typed, but is there a way to hint intellisense into the properties of the class?


thanks

sepehr



How to create call statement as object in SSAS

  

Hi Experts,

                 Any one please tell me how to create as object or attribute for the below Call statement.

Otherwise please guide me how to use the below statement in SSAS.


call SQLQuery.ExecuteSql(
    "Provider=SQLNCLI10.1;Data Source=DWHSRV01;Integrated Security=SSPI;Initial Catalog=Banking"
    ,"Exec Key 1")

 

Thanks,

Abdul2010


Matrix Column grouping - Total column incorrect when colum value is wrapped in a call to code

  

I have a column grouped matrix report that shows count, cost and duration.  Duration is time in seconds.  To format the time on the report as hh:mm:ss I send it through a code block that converts the int to a string. 

When the report is generated the total column is NOT code.convert(sum(Fields!Duration.Value)).  At first I thought it was taking the max value, then I thought it is was taking the first value.. not really sure how it is calculating the value.

I did trying wrapping the expression like this IIF(InScope("matrixgroup"), Code.Convert(Fields!Duration.Value), Code.Convert(Sum(Fields!Duration.Value))).  It didn't make a difference the column is still incorrect.

If I remove the Code.Convert from the column, the value is correct.

Does anyone have any suggestions?

 

 


interface and object

  
  public List<IProduct> GetProducts()
        {
            List<ProductSizeAndPrice> s = new List<ProductSizeAndPrice>();     
       return s;
        }


  public partial class ProductSizeAndPrice :  IProduct
    {
}


I get the error :

Cannot implicitly convert type 'System.Collections.Generic.List<ProductSizeAndPrice>' to 'System.Collections.Generic.List<IProduct>

 

How can I make this inhirte?

 

thanks


I nead to send an "interface" from C++ to a managed .NET object

  

I have a Win32 application that loads a C++ DLL. This C++ DLL is compiled with IJW support to let me call Managed objects.  This worksperfectly and there are no problems here.  My problem is the opposite way.  I nead, from my .NET (c#)code to call back to the Win32 program.  How do I manage this?  PInvoke and COM is out of the Question.  It must be using an Interface or soething like that.

 

regards
Ole Morten Heien
HD Software
Norway


------------------------------------------- Ole Morten Heien HD Software / Advisor AS -------------------------------------------

Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset' in BIDS

  
Hello.
I'm using BIDS for working with SSAS. I have bug with New Named Query feature.
Steps to reproduce:
1. Set up any data source.
2. Set up new data source view with any tables.
3. Right click on DSV body. Select 'New Named Query'
4. Switch to Generic Query Builder.
5. Type any query. For instance 'select name from sys.sysobjects'
6. Press Run button

After this message:
TITLE: Microsoft Visual Studio
------------------------------

An error occurred while reading data from the query result set.
Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0C733A7C-2A1C-11CE-ADE5-00AA0044773D}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

------------------------------
ADDITIONAL INFORMATION:

Unable to cast COM object of type 'System.__ComObject' to interface type 'IRowset'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0C733A7C-2A1C-11CE-ADE5-00AA0044773D}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). (System.Data)

---------

When I use interface as Contract in Web.config, I cannot call the service

  

I tried to use interface to define services but the JavaScript function will fail.  Without the interface, everything works perfectly.  Consider the following.

Consider the following.

 

namespace Enroll.ER.Services {
 [ServiceContract(Namespace = "Enroll.WebServices")] 
 interface IAccountService {
 [WebInvoke]
 [OperationContract]
 bool Checkin(string acctKey);
 ....
 }
}

namespace Enroll.ER.Services {
 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
 public class AccountService : Enroll.ER.Services.IAccountService {
 
 public bool Checkin(string acctKey); {
  ...
 } 
 ...
 }

 [DataContract]
 public class MyFaultException {
 [DataMember]
 public string Reason { get; set; }
 } 
 
}

Help - Cannot call webservice Get error: Server was unable to process request. --> Object reference

  
Here is my code, I don't fully understand the erro because I have instantiated all objects
Any help or advice appreciated.
  
Dim transactionResult As PremiumCredit.TransactionResult = New PremiumCredit.TransactionResult
        Dim newBusiness As PremiumCredit.NewBusiness = New PremiumCredit.NewBusiness
        Dim transferEngine As PremiumCredit.XMLTransferEngine = New PremiumCredit.XMLTransferEngine
        'Build up NewBusiness Object
        newBusiness.AddCoverCode = String.Empty
        newBusiness.BankAccountName = Session("BankAccountName").ToString
        newBusiness.BankAccountNumber = Session("BankAccountNumber").ToString ' 02149187
'Populate the rest of new Business object etc
        System.Net.ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
        Try
            transactionResult = transferEngine.Crea

Thinking about new C# method prototypes: object as dictionary

  
I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

Using jQuery to directly call ASP.NET AJAX page methods

  
Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend