|
Designing applications will lead to class libraries. Writing a toolkit is hardly a backward process. Yes, realizing that additional features could be abstracted from applications often happens, but even writing multiple applications at the same time and saving stuff off doesn't really make for a good class library from which applications should be based.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
When you design an application, you usually talk about the classes that will play a role in the life of the application. Classes such as Customer, Order, Product, etc, are application-specific classes that are designed to meet that particular application's needs. You can put them inside a separate DLL and call them a "class library" if you like, but chances are that they'll only be used by one application.
As you start developing the application, you'll notice that the underlying class library (.NET) will not provide all the functionality you need. So you'll end up extracting some of that functionality into a separate DLL to become part of a generic class library.
The main difference between the application-specific class library (A) and the generic one (G) is that A needs to be created/considered every time an application is started, while G is always there and continues to grow as more applications are written.
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
You must deal with small applications with a limited scope, then.
I'm talking about interfaces, abstract control classes, utility classes like a preferences provider pattern, configuration sections for those classes, etc. etc.
The framework I architected for our large industrial engineering application is vast and not application-specific until you get a little further up the dependency hierarchy.
Microsoft Office is the same: They have their toolbar code, their their persistence code, the task bar code, etc. They get used in all the products. It's a very abstract design that is not really product specific (depending on your scope of "product").
I guess it really matters what you need to abstract away. Many applications start with a UI toolkit and that tends to get reused throughout a company.
Another factor is that there isn't too levels of abstraction when it comes to toolkits vs. applications. Typically there's many, as with our application. There's a base toolkit (UI, persistence model, COM-like interfaces), a goal-oriented tookit on top of that with additional features, a product-specific toolkit, then the application itself.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the insight.
I admit I've never had to build something that large. It's usually been broken in 3 layers:
1. Generic Toolkit (reusable across applications, continually growing)
2. Application Toolkit (reusable within the application, sometimes extending Generic)
3. Application classes (usually extending the Application toolkit)
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
Hey Guys!
I am currently working on a Project, but now facing a problem in how to Monitor a Specific port for Data that is going from my computer to the outer world. E.g. I want to monitor port 'xyz' to check what is goind outside from my computer through this port.
Can anybody help me to solve this problem.
Give Room to Grow your Knowledge by Sharing your Experiences with Others
|
|
|
|
|
Download WinPcap and the associated Analyzer from http://winpcap.polito.it/[^]. You can also use Ethereal (port from *nix), but that still requires the WinPcap library (which, in case you're wondering, is partly founded by Microsoft so it's pretty safe and it is a common lib to find IT-folk using).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In Command-Mode (in VS.NET) I entered (after a breakpoint):
sLine.IndexOf("\"OPEN\",\"OPEN\"")
and got:
error: 'sLine.IndexOf' does not exist
why that?
sLine got a value as
string sLine="blabla";
Ariadne
|
|
|
|
|
When you opened the Command Windows and typed sLine.IndexOf("\"OPEN\",\"OPEN\"") , was it after a > prompt? If so, this is your problem. You can make evaluations in Command Mode, but you can't execute code. You have to switch to Immediate Mode first by issuing the immed command.
...Open a Command Window to Ctrl-Alt-A...
Command Window
>immed
sLine.IndexOf("\"OPEN\",\"OPEN\"");
cmd
>_
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
no that is not the problem. I am in the immed-mode.
I get the value of
sLine<br />
sLine.Length
but not of any method of sLine like
sLine.IndexOf(..)<code><br />
<br />
<br />
Ariadne
|
|
|
|
|
I don't have that problem at all. Are you sure sLine is a String ?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a c++ application that needs to retrieve information from my company's server. I decided to build a c# webservice. So far it works fine. I need to add some security since I pass userid and password. But my main concern is that this webservice will only be used by our applications and I don't want it to be public to others, so that they cannot view the schema and cannot see the page that shows how to make a HTTP GET/POST and SOAP request.
Is there a way to make the webservice not available to public ? or at least hide the schema/request pages ?
|
|
|
|
|
If you're looking to add security to your web services, take a look at the Microsoft Web Service Enhancements (WSE)[^]. 2.0 was recently released. With a few simple changes to your server and clients, you can use strong authentication protocols (or a simple username/password, though I recommend at least hashing the password using MD5 or SHA1, which is easily supported by the WSE), encryption, signatures, addressing (routing), etc.
If you want it private, simply don't expose it to the public. Unless it needs to be on your Internet web server, just use it on your intranet. If you need to put it on your Internet server (say, for an extranet) then use IP address blocking (IIS feature) or features in the WSE. The latter won't prevent them from seeing the WSDL, but unless your business is about the WSDL schema and not the data that's transferred, this really shouldn't be a problem.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
If you're looking to add security to your web services, take a look at the Microsoft Web Service Enhancements (WSE)[^].
The client application is built under VC++ 6.0. So, for now I am using sockets to connnect and retrieve the information. I was thinking about using SSL socket. I think there are some examples on codeproject.
Heath Stewart wrote:
If you want it private, simply don't expose it to the public. Unless it needs to be on your Internet web server, just use it on your intranet
The client application is a Windows application that access the service through the Internet. It connects to our company's Web server and retrieve some data to process/display. My main concern is that service should only be available to the client applications and not to the public. If I could hide the shema returned when you point a browser to the .asmx file, that would be a good start. Then there is the ?WSDL.
It looks like there is no easy way and will have to write a .ASP page which does basically the same thing. The problem is returning the XML code, with a webservice it's all very easy.
Possible solution: Have the .ASP page call the webservice, which would not be public, and simple return the data. The .ASP would just act as a bridge between client and webservice.
|
|
|
|
|
Everything from handling requests to .asmx?WSDL to generating the WSDL itself (as well as the "human-readable" HTML output for a service) is configurable. Spend some time reading the class library documentation for the System.Web.Services and child namespaces.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Here's what I found:
Since this webservice will only be used by some client applications that already knows the schema, to hide the documentation of the web service, there is a key that can be set in the web.config file.
<br />
<?xmlversion="1.0" encoding="utf-8"?><br />
<<configuration><br />
<system.web><br />
<!--<br />
HIDE THE DOCUMENTATION FOR THE WEB SERVICE<br />
--><br />
<webServices><br />
<protocols><br />
<remove name="Documentation"/><br />
</protocols><br />
</webServices><br />
</system.web><br />
</configuration><br />
|
|
|
|
|
You can also set a custom page to be displayed for the WSDL documentation:
<?xmlversion="1.0"encoding="utf-8"?>
<configuration>
<system.web>
<!--
Custome help page\
-->
<webServices>
<wsdlHelpGeneratorhref="helpPage.aspx"/>
</webService>
</system.web>
</configuration>
It can also be a .html page. So you can display what ever you want.
A third possibility is to process the request from Application_BeginRequest function. You can check if the request has a ?wsdl to it and throw a http exception.
All these examples can be found here: http://www.15seconds.com/issue/040609.htm
|
|
|
|
|
is there any way to promote programatically a directory
(located within inetpub directory subtree) to web application?
Also I would like programatically add new IASPI mapping
(for some custom file extension to particular DLL)
for this newly created web application.
Thanks for help
Michał Januszczyk
|
|
|
|
|
You can do both programmatically using either the IIS WMI provider or the ADSI provider.
For the WMI provider, use the System.Management classes, and for the ADSI provider use the System.DirectoryServices classes.
Try the following google search for lots of examples or refine it to find exactly what you want. Documentation for the IIS WMI and ADSI providers can be found on MSDN[^].
http://www.google.com/search?q=add+virtual+directory+programmatically+to+iis[^]
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank You!
This is exactly what I needed.
|
|
|
|
|
Hi EveryBody,
I used the later code to handle some messages sent to my application
and it works, but my question is how to handle messages sent for child applications of my application(parent)
<br />
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]<br />
protected override void WndProc(ref Message m)<br />
{<br />
switch (m.Msg)<br />
{<br />
<br />
case WM_SIZING:<br />
MessageBox.Show("Sizing");<br />
return ;<br />
case WM_SIZE:<br />
MessageBox.Show("Size");<br />
if(m.WParam==(IntPtr)SIZE_MINIMIZED)<br />
MessageBox.Show("SIZE_MINIMIZED");<br />
else if(m.WParam==(IntPtr)SIZE_MAXIMIZED)<br />
MessageBox.Show("SIZE_MAXIMIZED");<br />
return;<br />
<br />
case SW_MAXIMIZE:<br />
MessageBox.Show("SW_MAXIMIZE");<br />
return;<br />
<br />
case WM_MOVING:<br />
MessageBox.Show("Moving");<br />
return;<br />
}<br />
base.WndProc(ref m);<br />
}<br />
<br />
Please I need a very fast help.
Thank you .
|
|
|
|
|
Child applications? There's no such thing. Are you talking about child Windows or MDIChildren? Each form has it's own message pump. Your parent form will not get the messages meant for child forms.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave's right about the message pump. Some controls will send their parents messages, and these are documented in the Platform SDK (almost every control in Windows Forms encapsulates Windows Common Controls).
There is another way, though. Implement the IMessageFilter interface and add an instance of your implementation using Application.AddMessageFilter . This installs a message filter for the application's message pump, which will trap messages and allow you to process them (or even remove them) before dispatching them to their destination windows.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I can serialize my class with xmlserializer.
but when i add a DataTable typed property to my class, xmlserializer submit an error to me.
please guide to me.
|
|
|
|
|
We need the error mesage you're getting. We also need to know how your adding this DataTable to your class. Some code snippets would help alot.
Without these items, it's impossible to tell you what your doing wrong.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
using System;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Collections;
using System.Data ;
/* The XmlRootAttribute allows you to set an alternate name
(PurchaseOrder) of the XML element, the element namespace; by
default, the XmlSerializer uses the class name. The attribute
also allows you to set the XML namespace for the element. Lastly,
the attribute sets the IsNullable property, which specifies whether
the xsi:null attribute appears if the class instance is set to
a null reference. */
[XmlRootAttribute("PurchaseOrder", Namespace="http://www.cpandl.com",
IsNullable = false)]
public class PurchaseOrder
{
public Address ShipTo;
public string OrderDate;
/* The XmlArrayAttribute changes the XML element name
from the default of "OrderedItems" to "Items". */
[XmlArrayAttribute("Items")]
public OrderedItem[] OrderedItems;
public decimal SubTotal;
public decimal ShipCost;
public decimal TotalCost;
}
public class Address
{
/* The XmlAttribute instructs the XmlSerializer to serialize the Name
field as an XML attribute instead of an XML element (the default
behavior). */
[XmlAttribute]
public string Name;
public string Line1;
/* Setting the IsNullable property to false instructs the
XmlSerializer that the XML attribute will not appear if
the City field is set to a null reference. */
[XmlElementAttribute(IsNullable = false)]
public string City;
public string State;
public string Zip;
}
public class OrderedItem
{
public string ItemName;
public string Description;
public decimal UnitPrice;
public int Quantity;
public decimal LineTotal;
/* Calculate is a custom method that calculates the price per item,
and stores the value in a field. */
public void Calculate()
{
LineTotal = UnitPrice * Quantity;
}
}
public class Test
{
public static void Main()
{
// Read and write purchase orders.
Test t = new Test();
t.CreatePO("po.xml");
t.ReadPO("po.xml");
t.CreatCol() ;
}
private void CreatCol()
{
XmlSerializer serializer =
new XmlSerializer(typeof(MyCoulumnClollectionClass));
TextWriter writer = new StreamWriter("Hadi.xml");
MyCoulumnClollectionClass d=new MyCoulumnClollectionClass() ;
SCol s1=new SCol() ;
s1.FieldName ="stud_no" ;
s1.DisplayName="stud_displayname";
d.Add(s1);
s1=new SCol() ;
s1.FieldName="FN2" ;
s1.DisplayName="DN2" ;
s1.AAAA="====" ;
d.Add(s1) ;
serializer.Serialize(writer, d);
writer.Close();
}
private void CreatePO(string filename)
{
// Create an instance of the XmlSerializer class;
// specify the type of object to serialize.
XmlSerializer serializer =
new XmlSerializer(typeof(PurchaseOrder));
TextWriter writer = new StreamWriter(filename);
PurchaseOrder po=new PurchaseOrder();
// Create an address to ship and bill to.
Address billAddress = new Address();
billAddress.Name = "Teresa Atkinson";
billAddress.Line1 = "1 Main St.";
billAddress.City = "AnyTown";
billAddress.State = "WA";
billAddress.Zip = "00000";
// Set ShipTo and BillTo to the same addressee.
po.ShipTo = billAddress;
po.OrderDate = System.DateTime.Now.ToLongDateString();
// Create an OrderedItem object.
OrderedItem i1 = new OrderedItem();
i1.ItemName = "Widget S";
i1.Description = "Small widget";
i1.UnitPrice = (decimal) 5.23;
i1.Quantity = 3;
i1.Calculate();
// Insert the item into the array.
OrderedItem [] items = {i1};
po.OrderedItems = items;
// Calculate the total cost.
decimal subTotal = new decimal();
foreach(OrderedItem oi in items)
{
subTotal += oi.LineTotal;
}
po.SubTotal = subTotal;
po.ShipCost = (decimal) 12.51;
po.TotalCost = po.SubTotal + po.ShipCost;
// Serialize the purchase order, and close the TextWriter.
serializer.Serialize(writer, po);
writer.Close();
}
protected void ReadPO(string filename)
{
// Create an instance of the XmlSerializer class;
// specify the type of object to be deserialized.
XmlSerializer serializer = new XmlSerializer(typeof(PurchaseOrder));
/* If the XML document has been altered with unknown
nodes or attributes, handle them with the
UnknownNode and UnknownAttribute events.*/
serializer.UnknownNode+= new
XmlNodeEventHandler(serializer_UnknownNode);
serializer.UnknownAttribute+= new
XmlAttributeEventHandler(serializer_UnknownAttribute);
// A FileStream is needed to read the XML document.
FileStream fs = new FileStream(filename, FileMode.Open);
// Declare an object variable of the type to be deserialized.
PurchaseOrder po;
/* Use the Deserialize method to restore the object's state with
data from the XML document. */
po = (PurchaseOrder) serializer.Deserialize(fs);
// Read the order date.
Console.WriteLine ("OrderDate: " + po.OrderDate);
// Read the shipping address.
Address shipTo = po.ShipTo;
ReadAddress(shipTo, "Ship To:");
// Read the list of ordered items.
OrderedItem [] items = po.OrderedItems;
Console.WriteLine("Items to be shipped:");
foreach(OrderedItem oi in items)
{
Console.WriteLine("\t"+
oi.ItemName + "\t" +
oi.Description + "\t" +
oi.UnitPrice + "\t" +
oi.Quantity + "\t" +
oi.LineTotal);
}
// Read the subtotal, shipping cost, and total cost.
Console.WriteLine("\t\t\t\t\t Subtotal\t" + po.SubTotal);
Console.WriteLine("\t\t\t\t\t Shipping\t" + po.ShipCost);
Console.WriteLine("\t\t\t\t\t Total\t\t" + po.TotalCost);
}
protected void ReadAddress(Address a, string label)
{
// Read the fields of the Address object.
Console.WriteLine(label);
Console.WriteLine("\t"+ a.Name );
Console.WriteLine("\t" + a.Line1);
Console.WriteLine("\t" + a.City);
Console.WriteLine("\t" + a.State);
Console.WriteLine("\t" + a.Zip );
Console.WriteLine();
}
protected void serializer_UnknownNode
(object sender, XmlNodeEventArgs e)
{
Console.WriteLine("Unknown Node:" + e.Name + "\t" + e.Text);
}
protected void serializer_UnknownAttribute
(object sender, XmlAttributeEventArgs e)
{
System.Xml.XmlAttribute attr = e.Attr;
Console.WriteLine("Unknown attribute " +
attr.Name + "='" + attr.Value + "'");
}
}
public class SCol
{
// public string FiledName
// {
// get
// {
// return m_fieldName ;
// }
// }
// public void SetFiledName(string f)
// {
// m_fieldName=f ;
// }
[XmlElement(ElementName = "TaxRate")]
public string FieldName
{
get
{
return m_ ;
}
set
{
m_=value ;
}
}
public string DisplayName ;
// ***** in this property , xmlSerializer submit error ***
public DataTable m_columnTable ;
private string m_ ;
[XmlElement]
public string AAAA ;
}
public class MyCoulumnClollectionClass : CollectionBase
{
//[XmlElement(ElementName = "Collection")]
//[XmlArrayAttribute("Items")]
public SCol this[ int index ]
{
get
{
return( (SCol) List[index] );
}
set
{
List[index] = value;
}
}
public int Add( SCol value )
{
return( List.Add( value ) );
}
public int IndexOf( SCol value )
{
return( List.IndexOf( value ) );
}
public void Insert( int index, SCol value )
{
List.Insert( index, value );
}
public void Remove( SCol value )
{
List.Remove( value );
}
public bool Contains( SCol value )
{
// If value is not of type Int16, this will return false.
return( List.Contains( value ) );
}
}
|
|
|
|
|