|
Ah...details: the heart and soul - and bane - of COM programming. It is a wild beast and difficult to tame at times.
When you say you're getting the same object, what exactly do you mean? The Item Moniker will be the same because the same moniker (though referring to different instances) is registered in the ROT. Do you get a duplicate file list or something?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I mean that after calling this method :
object[] GetActiveObjects(string ProgId)
{
while ...
{
prot.GetObject(pmon[0],out objReturnObject);
objs.Add(objReturnObject);
}
}
I get an array of N objects (N=number of MSDev instances) but when casting them into DSSharedObjects.IApplication and asking for the App.Documents I get for each one the same array of files...
Ahhh... (sigh) If only I could get different DSSharedObjects.IApplication objects !
- Éric -
|
|
|
|
|
I'm sorry, but I really don't know what's wrong in that case. Out of curiosity, though, does the documents list for one application object contain a complete list of all documents open in all instances of msdev.exe?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
No, the documents list for one application object contains only the list of the documents open in the first instance of msdev.exe in the ROT. No way to reach others. So it seems that all application objects represent the same one.
So finally all I have is the number of msdev.exe and I can interoperate with only one
I'm sure it's possible... what a pity to be in a deadlock
Anyway, thank you all the same !
- Éric -
|
|
|
|
|
Hi!
I am trying to grasp the usage of SOAP extensions, and was wondering if someone can help me with this scenario:
I have a command line client which invokes a webservice. In response, the webservice is sending some XML which I would like to validate. I understand that in the case where a client _calls_ a webservice, validation can be done in a SOAP extension for the request that is coming to the webservice. The same thing can be done for a request that is outgoing from the webservice.
In my scenario, the called webservice does need to know (or does not care)about validation, it simply sends out the response. I am not sure how I can validate a response from this webservice to my client (at the client side).
Can I use a SoapExtension here? In which case, how would I configure the client so that when it receives a response, the extension is used?
Thanks in advance!
|
|
|
|
|
There are no configuration sections to configure SOAP extensions on the client. Often times you can attribute your proxy methods with SOAP extension attributes to understand the extensions.
You should take a look at Web Service Enhancements 2.0, OR WSE 2.0, that was just released yesterday. These are classes that implement industry standards (like WS Addressing, WS Security, etc.) that make extensive use of SOAP extensions. That should provide quite a bit of insight, especially if you install the SDK and look over the examples.
Otherwise, you're responsible for parsing the SOAP extensions yourself on your client.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How to use this DBNull.IConvertible.ToDecimal Method
|
|
|
|
|
IFormatProvider formatter = CultureInfo.InvariantCulture.NumberFormatInfo;
decimal d = ((IConvertable)DBNull.Value).ToDecimal(null); When you see an explicit interface declaration like that, you must first cast it to the interface; then you can call the explicit interface method implementation (or get/set a property or handle an event).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
But I am getting I dont have reference to assembly...
do i need to include any classes..
Thanks for the immediate reply
|
|
|
|
|
You need to reference all necessary assemblies (in this case, mscorlib.dll which is always referenced unless you tell the compiler otherwise) and import the System namespace:
using System;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am able to do that...
after that also i am unable to convert DBNull value to decimal...
I have a decimal , if nothing is there in that i need to assign a dbnull value to that , but i am not able to do that
Once again thanks for the immediate response
|
|
|
|
|
Because DBNull.IConvertible.ToDecimal always throws an InvalidCastException . But I answered what you asked.
You might want to be more specific about what you're trying to do. If you need to insert a null value for a decimal field in a database, then you actually use DBNull.Value , not the decimal equivalent (which isn't even possible since value types - such as the primative types - can't be null).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is there anyway i can do that......
|
|
|
|
|
If you use parameterized queryies for example, you could use that as the value:
SqlCommand cmd = sqlConnection1.CreateCommand();
cmd.CommandText = "UPDATE MyTable SET DecimalField = @DecimalField WHERE ID = 1";
SqlParameter decimalField = cmd.Parameters.Add("@DecimalField", SqlDbType.Decimal);
decimalField.Value = myDecimal == 0m ? DBNull.Value : myDecimal;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath Stewart
Could u let me know the solution for this
I have a web page which contains two frames, I am redirecting the user to login page once session timeout, the problem in both the frames I am getting the login page. could anybody let me know how can i handle so that it will redirect to login page with out any frames....
|
|
|
|
|
This is a common problem with frames, which is why almost all web sites do not use them today. I would recommend designing your site using tables to layout your page with included components like headers, footers, and navigation bars.
If you insist on frames, you will have more problems. Make sure you use the target attribute of the A tab wisely.
As far as deirecting a user to a single login page, this isn't possible using the .NET FCL's authentication modules. You would have to write your own authentication module that takes target frames into account. The ASP.NET authentication modules do not do this.
For more information on how to do this, read about IHttpModule and the existing authentication modules like FormsAuthenticationModule to see how they work, even using ildasm.exe that comes with the .NET SDK (if you know how to read IL) or ".NET Reflector", which you can google for (both a disassembler and decompiler with a nice interface - I currently do not have the link available since I'm on vacation).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
have a problem
Desc:
I am populating a window from parent window, i will perform some action on the child window and i will click OK button, once i click OK i need to pass a server side created object back to parent window.can you let me know how i can do that?
Thanks in advance
|
|
|
|
|
You can't. Once again, HTTP is simple client request/server response. The best you could do is pull the server from the client to watch for changes using the HTTPXML component or the WebService behavior, both supported only by Internet Explorer (Mozilla has a couple of possibilities as well).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Please can you let me know how can i do that? ii have never worked on HTTPXML COMPONENT
|
|
|
|
|
|
Does anyone know how to call an external program in C#?
Thanks,
Tim Cole
|
|
|
|
|
|
|
Hi,
I have Scripting.DictionaryClass instance passed back to one of my methods from a COM object. I can see that this DictionaryClass instance has 4 items inside it. How can I retrieve the key/value pairs from this object ? I've tried cycling through it via an IEnumerator object but I get an "Invalid cast" exception. I've tried casting to to a System.Collections.Dictionary object but that doesn't seem to work either. I've tried using the Scripting.Dictionary.Items() method but results in an invalid cast also. There are also no getters/setter nor can I index into this object. Anyone have any other solutions ? Thanks in advance...
-Pete
|
|
|
|
|
The Scripting.Dictionary has nothing to do with the .NET FCL, so it doesn't implement IDictionary . It is an RCW (Runtime Callable Wrapper) to a COM object and you must use the COM methods and properties it exposes. The typelib importer (tlbimp.exe) does, however, provide the GetEnumerator which enumerates over the keys, but this is only defined by the DictionaryClass (though Keys() would as well since it's actually an object[] array that you could cast to IEnumerable ).
Take a look at this example code:
using System;
using Interop.Scripting;
public class Test
{
static void Main()
{
IDictionary dict = new DictionaryClass();
Add(dict, "a", 1);
Add(dict, "b", 2);
Add(dict, "c", 3);
object[] keys = (object[])dict.Keys();
for (int i=0; i<keys.Length; i++)
{
object key = keys[i];
object value = dict.get_Item(ref key);
Console.WriteLine("{0}: {1}", key, value);
}
object a = "a";
Console.WriteLine("\na={0}", dict.get_Item(ref a));
}
static void Add(IDictionary dict, object key, object value)
{
dict.Add(ref key, ref value);
}
} The only reason I don't use a foreach loop (uses the IEnumerable implementation) is because the key variable would be read-only, which you can't use with a ref , which is required to call get_Item .
Microsoft MVP, Visual C#
My Articles
|
|
|
|