In my SOAP webservice, i am referencing a dll[.Net Project] ,which contains all the methods in the webservice. I changed data type of one of the method in my dll project ,rebuild it and refrenced the dll in webservice. But still,its pointing to the old dll reference and throwing errors like below,
System.MissingMethodException: Method not found: 'System.Collections.Generic.List`1<COS.IPEDS.Business.School> COS.IPEDS.Business.School.GetSchoolsByCipAndZipCodeByLevel(System.String, Int32, System.String, System.String, System.String ByRef)'.
at ShortTermTraining.findInstitutions.GetInstitutionsProgramsByCipCodeLevelZip(String zipCode, Int32 radius, String cipCode, String awardLevel, String ErrorMsg)
Is there any other place,should I check ?
Thanks,
Vanitha
Related
I have a COM object written in C#. Under some circumstances, the COM object may throw an Exception with a descriptive message if it encounters an error (for example throw new Exception("error message")).
This COM object is called from VB6 code and from C++ code.
From the VB6 code, I can retrieve the error message using Err.Message.
In C++, I get an HRESULT 0x80131500 as specified in the System.Exception documentation.
Once I have this HRESULT in C++, how can I get the error message of the Exception (Exception.Message) like the message returned by Err.Message in VB6?
I searched the web and found a few examples using FormatMessage and _com_error, but none of these return the message I want.
Updated.
Try to QueryInterface the failing object for the ISupportErrorInfo interface, then call the InterfaceSupportsErrorInfo method with the REFIID of the interface throwing the exception. If it returns S_OK, then just calls the GetErrorInfo function to get an IErrorInfo interface. Then use the GetDescription method.
I have a com dll that gets used in a c++ project. I have not registered the dll but its in the same solution. My application continuously breaks and I found that it breaks here
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown), reinterpret_cast<void**>(&pIUnknown));
because I don't have a com class with that guid (rclsid). I did more digging and I found that it gets the guid from a .tlh file in a temp directory but the guid differs from my code.
.tlh file
struct __declspec(uuid("b10a18c8-7109-3f48-94d9-e48b526fc928"))
DocMapEntry;
// [ default ] interface _DocMapEntry
// interface _Object
// interface IDocMapEntry
c# code (com visable dll)
[ComVisible(true)]
[Guid("E98676B9-1965-4248-A9B6-74EC5EE5385A")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IDocMapEntry
{
int Offset { get; set; }
int PageOffset { get; set; }
int PageNumber { get; set; }
}
I tried changing the value to the correct value but it continuously gets changed and visual studio asks me to reload.
When I look at the class using com explorer I get a different clsid, and when I try to unregister it, it completes successfully but the item is still there and the file location is mscoree.
my c++ application uses the guid in the .tlh file but doesn't find the file.
public class DocMapEntry : IDocMapEntry
{
...
}
My questions are.
Do I need to register my com dll for this to work?
how can I set the guid for the class?
Why would it create a temp .tlh file with the wrong guid? (optional)
why can't I change this file? (optional)
Thank you.
public interface IDocMapEntry
COM strongly distinguishes between a CLSID and a IID. The IID, the interface identifier, identifies an interface implemented by a COM object. We can see that one, you specified it with the [Guid] attribute. You'd pass it as the 4th argument of CoCreateInstance(), the one where you now pass the IID of IUnknown.
What you need is the CLSID, the class identifier. We can't see it in your snippet, it is the one for whatever class implements your IDocMapEntry. With some odds that it is named DocMapEntry. And additional odds that you didn't give it a [Guid] so the CLR will auto-generate one for you. Note that it will change when you modify the class, one possible reason for CoCreateObject() to fail.
Forgetting to register the .NET assembly with Regasm.exe /codebase is another reason, you stated as much in your question. This is required or COM will not be able to find the DLL and fails the call with error code 0x80040154, "Class not registered". Having it in the same solution is not sufficient, COM search rules are not anything like those used by .NET.
Also note that you are exposing the internals of the class, avoid that by applying the [ClassInterface(ClassInterfaceType.None)] attribute on the class.
No you do not have to register the COM DLL but you do need to register an object responsible for creating the COM objects. Use do this in your application by calling CoRegisterClassObject after the COM subsystem has been initialized (by calling CoInitialize or CoInitializeEx).
IClassFactory *factory = new ObjectFactory();
// Register the factory responsible for creating our COM objects
DWORD classToken;
HRESULT hr = CoRegisterClassObject(
Object_CLSIID,
factory,
CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE,
&classToken);
// Now we can create the objects
Object *obj = nullptr;
hr = CoCreateInstance(
Object_CLSIID,
nullptr,
CLSCTX_LOCAL_SERVER,
Object_IID,
reinterpret_cast<void**>(&obj));
Not sure why it's creating a temporary .tlh but I suspect it's something in your build settings - possibly in the build steps.
Is your COM object in a C# dll ? If yes, did you run regasm previously in your system, which could have registered the COM dll.
Guid("E98676B9-1965-4248-A9B6-74EC5EE5385A"): This is your interface GUID, not your component guid.
You should have a GUID declared for COM object in the implementation class, which should be b10a18c8-7109-3f48-94d9-e48b526fc928.
Why would it create a temp .tlh file with the wrong guid?
Are you sure you have not imported the COM dll using #import keyword.
I'm trying to build an extension for Firefox. This extension uses an XPCOM component (a C++ dll). I'm compiling the DLL, compilation is OK.
I also succeeded in building a JS code which instanciates the object from XPCOM:
try {
greenfox;
return true;
} catch( e ) {
alert( e );
return false;
}
The object returned is this one:
QueryInterface
QueryInterface()
__proto__
[xpconnect wrapped native prototype] { QueryInterface=QueryInterface()}
QueryInterface
QueryInterface()
Everything is fine, except I can't call the function which are supposed to be in my XPCOM component.
Here is my IDL file:
[scriptable, uuid(ec8030f7-c20a-464f-9b0e-13a3a9e97384)]
interface nsISample : nsISupports
{
attribute string value;
void writeValue(in string aPrefix);
void poke(in string aValue);
void start();
double stop();
};
When callingstart() function, I get the Javascript error: "is not a function"
greenfox.start();
Do you have any idea? It seems like no function is exposed in my XPCOM.
You seem to be looking at an object exposing only the nsISupports interface. Your interface (nsISample) won't get exposed by default, you have to explicitly request it. You can do it for example by instantiating your component like this:
var greenfox = Components.classes["..."].getService(Components.interfaces.nsISample);
greenfox.start();
Alternatively, you can also call QueryInterface on an object you already have:
greenfox.QueryInterface(Components.interfaces.nsISample);
greenfox.start();
Generally, I wouldn't recommend using a binary XPCOM component for reasons outlined here, maintaining them requires way too much effort. I would rather suggest compiling a regular DLL and using it via js-ctypes. Reference a binary-component to js-ctypes mentions how you would locate a DLL inside your add-on to use it via js-ctypes.
Do you call QueryInterface with your uuid? It is necessary to call it before using the component instance created. Does your usage match what's in here?
If you don't want to deal with XPCOM you can use js-ctypes.
I have a web service that sends a struct to a client program.
I need to pass an arraylist of string values as one of the properties of this struct, but by the time it gets to the client program its type is 'object'. Once it gets back to the client program, how can I convert this Object datatype back into the arraylist?
Unless you're stuck at .NET 1.1, don't use ArrayList. Try returning a List<YourStruct> instead.
The problem was the way I was attempting to explicitly create an arraylist and then setting it equal to the returned property from the struct; here's the correct way to do it - some weird VB implicit thingy. (sorry, never drank the VB kool-aid)
Dim ReturnedArrList As New ArrayList(structReturned.arrReturnedArrayList)
Ok, I'm really stumped with this one. I have this Compact Framework application which calls your standard .NET web service. This has been working pretty well for a while, but recently we were asked to make this software work on another Windows CE device.
This new device seems to have been manufactured in Korea, and has some weird/buggy default configuration. Regional settings on the Control Panel show that the locale is set to English(United States) and the User Interface Language and Input Language settings have this value set as well.
There are some weird issues though. On Windows Explorer, the usual '\' characters that are used to separate folders, appear as a crossed-out W. The small input panel has some characters that are also wrong, some look clearly Korean.
The problem with all of this, is that for some reason I get a PlatformNotSupportedException, when calling a Web Service method that returns a DataSet. On the debugger I can see that the the CurrentUICulture is properly set to 'en-US', but somehow this doesn't keep the program from running into this issue.
I think that the Korean language installed on the device is conflicting with the culture configuration of the Web Service, but I don't have a clue about the details, and I don't know how I could fix it. Any help would be greatly appreciated. Thanks.
This is the full stack trace:
System.PlatformNotSupportedException - at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
at System.Globalization.CultureInfo..ctor(String name)
at System.Data.XSDSchema.HandleDataSet(XmlSchemaElement node, Boolean isNewDataSet)
at System.Data.XSDSchema.LoadSchema(XmlSchemaSet schemaSet, DataSet ds)
at System.Data.DataSet.ReadXSDSchema(XmlReader reader, Boolean denyResolving)
at System.Data.DataSet.ReadXml(XmlReader reader, XmlReadMode mode, Boolean denyResolving)
at System.Data.DataSet.ReadXmlSerializable(XmlReader reader)
at System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader)
at System.Xml.Serialization.XmlSerializationReader.DeserializeSerializableElement(LogicalType deserializeAs, Accessor accessor, Fixup fixup, Object fixupTarget, String identifier, Boolean emptyValue, Boolean nullValue)
at System.Xml.Serialization.XmlSerializationReader.deserializeElement(Accessor accessor, Fixup fixup, Object fixupTarget)
at System.Xml.Serialization.XmlSerializationReader.DeserializeElementMember(MemberValueCollection members, Object fixupTarget, Hashtable internalState, Boolean& firstElement)
at System.Xml.Serialization.XmlSerializationReader.deserializeMembers(MemberValueCollection members, Object fixupTarget)
at System.Xml.Serialization.XmlSerializationReader.DeserializeComplexElement(LogicalType deserializeAs, Accessor accessor, Fixup fixup, Object fixupTarget, String identifier, Boolean emptyValue, Boolean nullValue)
at System.Xml.Serialization.XmlSerializationReader.deserializeElement(Accessor accessor, Fixup fixup, Object fixupTarget)
at System.Xml.Serialization.XmlSerializationReader.DeserializeElementMember(MemberValueCollection members, Object fixupTarget, Hashtable internalState, Boolean& firstElement)
at System.Xml.Serialization.XmlSerializationReader.deserializeMembers(MemberValueCollection members, Object fixupTarget)
at System.Web.Services.Protocols.SoapMessageParser.execute()
at System.Web.Services.Protocols.SoapMessageSerializer.Deserialize(XmlReader reader, SoapHttpClientProtocol client, LogicalSoapMethod soapMethod, Boolean soap12)
at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)
The culture you're trying to use is not a neutral culture and the underlying Win32 locale is not supported by the device's OS. In any case, for a web service, wouldn't you want to use the invariant culture?
EDIT: The schema for the DataSet needs to specify a culture by way of Microsoft schema extension. Try adding the namespace declaration
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
to your schema, and the attribute
msdata:Locale=""
to the xs:element that represents the root of the DataSet, to force the use of the invariant culture; a non-empty string value will be passed to the CultureInfo(string) constructor. Otherwise, if the attribute
msdata:UseCurrentLocale="true"
is present, whatever the device's current locale is will be used. If neither attribute is present, it's hardcoded to LCID 0x0409, which is US English.
You either need to change the target platform to X64 or X32 from your CSproj properties build settings or just simply turn off the said System.PlatformNotSupportedException from exception settings under debug windows option.