|
I never really had a hard time understanding it at all. In fact, just the other week I finished doing a large amount of hacking to the generated MSI package for the AutoCAD OEM we've licensed to add a lot of extra files and actions that it didn't know about when building the MSI package from it's own template. I did all this using Orca. I do plan at some point to write a simple script or application to automate this (to avoid stupid mistakes including typos or just forgetting something), but it wasn't hard to do if you understand it.
Windows Installer is a great runtime and I'll never go back to a proprietary installer technology like InstallShield (which I used a little before Windows Installer). The transaction functionality is excellent, and correctly authored MSI packages are great for advertised and administrative installations, something I haven't seen in proprietary installer technologies from the likes of Wise or InstallShield.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
For information, know that InstallShield uses MSI packages if you ask for it. if you select an MSI project under InstallShield, it will show you a series of interfaces to help you to fill easily the tables needed to build the MSI/updates package with all actions or dialog boxes you need.
Both: Wise and InstallShield are good tools, they are just different... like Maya or 3DS...
Best regards.
There is no spoon.
|
|
|
|
|
I know. They used to have a separate IDE for Windows Installer but recently (last time I checked) bundled it with InstallShield Developer, which is much more expensive and - if all you want is a Windows Installer IDE - isn't worth it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I writing an N-tier application, where I will used strongly typed DataSets as data transport objects between some tiers.
The application consumes a web service. By default VS has created a proxy and a number of classes that are used to hold the data the web service returns, ie classes that mirrors the result xml structure. I want to move to DataSets instead.
Is there a clever way to make a web service proxy automatically fill a typed DataSet instead of the auto-created classes when I call the web service? Observe that this web service does not return a DataSet per se (this would be simple then), but a structure that would easily be held within a DataSet.
Manually I can look inside the wsdl, extract the schemas, let VS create typed DataSets from those schemas, write code that consumes the web service through the proxy, move over all retrieved data to my DataSets, done. Since this seems like a common scenario, I'm just hoping that VS has an automated way of doing this. What would be the easiest way?
Kind regards,
/Björn Morén
Sweden
|
|
|
|
|
Does the Web Services return a typed DataSet ? IIRC, if it does the generated proxy should create a typed DataSet as well. I could be wrong - it's been a while since I consumed a Web Services (I have - a lot - it's just that now the clients already have the proxies and I haven't had a need/desire to consume another WS lately).
If not, you can always write your own proxy - it's really not that hard - so that it uses a typed DataSet . Just look at the source for the generated proxy and you'll see how easy it is to create your own, pretty much as you suggested you might do. I'm not aware of any automated method that VS.NET provides, since it's only automated method of generating a proxy us what you've already used (similar to wsdl.exe, if it doesn't actually use it already).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the reply Heath.
If the web service returns typed DataSets, then the proxy will return untyped (regular) DataSets, but the content can easily be moved to a typed DataSet by use of the DataSet.Merge method. But my problem is that the web service does not return a DataSet, even though the actual xml structure is very similar. I'm curious why I havn't found anything fruitful Googling around for this. What would be a really good setting for the proxy generation would be a checkbox: "return as [] DataSet or [] object hierarchy classes".
I have some ideas I will try shortly:
- Getting hold of the web service reply in original xml format, and deserializing it into the typed DataSet. Weakness: Probably requires some tweaking of the xml.
- Manipulating the wsdl so that VS thinks that DataSets are returned, and creates the proxy to return DataSets. I have my doubts that this will work automatically.
- Writing a generic method that by use of reflection can move an object hierarchy into a typed DataSet. Ugly.
Writing my own proxy might be a good alternative, thanks for the tip. It probably can be very generic too (or based on a very generic base class), so it can be used for all "web service reply -> typed DataSet" scenarios.
|
|
|
|
|
If the XML returned for the DataSet is in the correct format (which is should be, since DataSet are marshaled as XML even for the BinaryFormatter provided in the FCL), you can always use DataSet.ReadXml to read it into a DataSet .
I'd have to agree with you as well that modifying the WSDL would probably not yield the result you're looking for.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry, you were right, VS creates a strongly typed DataSet for the proxy, not a regular DataSet as I wrote.
It would be interesting to find out how the SoapHttpClientProtocol.Invoke method finds out what classes to use when it deserializes the incoming web service response. My guess is that it uses reflection to search the current assembly and current namespace for class names that simply matches the xml-tags in the response. Would be glad if anyone had any input on this.
What still puzzles me is this: I can find numerous examples that show how easy it is to pass a typed DataSet from a web service to a web service consumer, as long as you use VS to create both ends. Very neat, VS creates all code for you. But isn't web services about platform independence? So when a Java web service exposes data in a DataSet-similar format (which by the way could be just any format, the DS is very flexible), VS wont help me with code to fill a typed DataSet? I have write a lot of plumbing code. Sure, I can take the object hierarchy, serialize it into xml, and read the xml into the DataSet, but that isn't a very optimised way of doing things.
|
|
|
|
|
VS.NET knows nothing more than what the WSDL tells it, so even if you exposed an XML Web Service created in Java, a DataSet -like schema should still create a typed DataSet . Even if it doesn't, nothing is stopping you from created a typed DataSet as we discussed before.
If you're interested in how the classes work, I suggest you learn how to at least read MSIL (Microsoft Intermediate Language, extensions to Common IL) and use ildasm.exe from the SDK to examine the classes, or use a decent decompiler like .NET Reflector[^], although sometimes it can't properly decompile the IL so you have to resort to reading IL in those cases, anyway. It's how I learned so much about the internal workings, and can provide insight into better ways of coding your classes by seeing how Microsoft does things, as well as designing your classes to better utilize the FCL knowing how things work internally.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hai there,
i am an middle level c# Programmer. in my current project i want to know all ip address of machines that are connected in my local network.
|
|
|
|
|
Hi!
I have a piece of code that maybe helps.
<br />
try<br />
{<br />
System.Net.Dns.GetHostByAddress(serverAddress);<br />
}<br />
catch (System.Net.Sockets.SocketException)<br />
{<br />
}<br />
The exception is thrown, when no computer with the specified address is reachable. The serverAddress can either be a string specifing an IP-address or an object of IPAddress class. See documentation for further information.
Maybe you could build a loop and process this test for every address possible in your local network. This may be not very efficient, but at least it's better than nothing
|
|
|
|
|
thanks for DrGreen (pedrosferreira@hotmail.com) 's suggestion first.
then here is my question:
i get many small bitmap parts from a large bitmap and turn them into stream which can be sent through socket. of course every part has its original coordinary(x,y), so i can restore the original large bitmap correctly .
now ,i need to draw the the recived image parts to a bitmap in memory .
How to write the code ?
please show me the way.
|
|
|
|
|
In this example dest is the destination bitmap and SourceBmp is the source bitmap, I've used x and y loops to simulate putting many smaller (48x48 pixedl) bitmaps into one large (192x192 pixel) bitmap.
Bitmap dest = new Bitmap(48*4, 48*4);
Graphics g = Graphics.FromImage(dest);
for(int x = 0; x<4; x++)
{
for(int y = 0; y<4; y++)
{
g.DrawImage(SourceBmp,x*48,y*48,48,48);
}
}
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event[^].
|
|
|
|
|
I Have a class that inherits from the Frameworks DataTable, and i wish to serialize it.
I added the Serializable attribute to the class but when i deserialized i got an exception that said that i needed a constructor that could create the instance by deserialization. Then i noticed that the private members of my class were not serialized since the DataTable class implements ISerializable, so i need to override the GetObjectData method, but it is somehow defined as private in the DataTable class (According to the Reflector).
If anyone encountered a problem like this and knows the solution i would appreciate it.
I Tried it with the HashTable class and didn't have any problems, this is only with the DataTable class.
|
|
|
|
|
GetObjectData is an exlicit interface implementation. Depending on what you add to your derivative DataTable class, you probably don't need to override this anyway. To define the constructor, create a constructor for your class (any access modifier will work since reflection is used to invoke it) that follows the following pattern/example:
protected MyDataTable(SerializationInfo info, StreamingContext context) {}
You should also look into typed DataSet . These can easily be created in VS.NET (add a new DataSet item to your project from Add-<Add New Item). This is an easy way to create a typed DataSet with typed DataTable s and DataRow s (actually, the columns themselves) that are faster when accessing data by their column name and use the default serialization provided by the DataSet and DataTable to serialize your typed DataSet correctly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My problem is not with the deserialization, it is with the serialization it self.
My private members are not serialized so thats why i want to use the GetObjectData method, but when i use it i cannot call the base class's method since it is private and there for i can either serialize my members, or my bases members but not both.
I cannot use a DataSet because it will cause too many changes in my code.
I would appreciate any help on this matter.
|
|
|
|
|
You can call it. Like I said, it's an explicit interface implementation, which means you must cast the base to the interface in order to call it like so:
((ISerializable)base).GetDataObject(info, context); (where info and context are your parameters for your implementation of GetDataObject ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The compiler does not permit this call, it said that :
'the keyword base is not allowed in this context'
|
|
|
|
|
So it does. Guess you'll have to refactor your code, then.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi every one:
I want to shutdown computer .
but I can not succed in xp.The ExitWindow can not
work .Could you give me some addvices?
|
|
|
|
|
ExitWindows can only log-off the current user if declared correctly. You must P/Invoke ExitWindowsEx in order to specify any shutdown parameters, like the following sample shows:
using System;
using System.Runtime.InteropServices;
public class Test2
{
static void Main()
{
ExitWindowsEx(ConvertFlags(ShutdownFlags.Logoff), 0);
}
[DllImport("user32.dll")]
private static extern bool ExitWindowsEx(
[MarshalAs(UnmanagedType.SysUInt)] IntPtr flags,
[MarshalAs(UnmanagedType.U4)] int reason);
private static IntPtr ConvertFlags(ShutdownFlags flags)
{
return new IntPtr((int)flags);
}
[Flags]
private enum ShutdownFlags
{
Logoff = 0,
Shutdown = 1,
Reboot = 2,
Force = 4,
Poweroff = 8,
ForceIfHung = 16
}
} You'll notice that the first parameter is declared as an IntPtr . This is because UINT is an unsigned int , which is architecture-dependent. On 32-bit operating systems, this is a 32-bit unsigned int. On 64-bit operating systems, this is a 64-bit unsigned integer. It's marshaled as an UnmanagedType.SysUInt for portability.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you.
but we must have purview when we want to shutdown in xp.
we can not use ExitWindowsEx only
|
|
|
|
|
Be specific in your requests, then. You didn't say you wanted a dialog. In that case, P/Invoke RestartDialog or RestartDialogEx from shell32.dll.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you:
I want to say we must get privileges in xp to shut down.
we can not use ExitWindow only.
sdfasd
|
|
|
|
|
You need to P/Invoke AdjustTokenPrivileges using the SE_SHUTDOWN_NAME or something like that, then. It will all be documented in the ExitWindows and ExitWindowsEx function documentation in the Platform SDK in the MSDN Library[^]. You should read it for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|