|
Hello people, I have an Web Application and I need to get the Mac Address from client computer for security reasons. So I tried to do this by using Windows Control, but Windows Control isn't working when I call for System.Management objects like when I try to get the Mac Address. Explorer shows an alert about SecurityException. Anyone knows how to do this? another solution?
tks
Wender Oliveira
.NET Developer
|
|
|
|
|
You're trying to get the MAC address of a client on the server side of your ASP.NET application. The short answer is, you can't. Not because of the security restrictions either. Simply because when you try and do an ARP resolve on the IP address, you'll get the MAC address of the NIC on the side of the router that the server is on, not the client machine. There is no method of getting the MAC address of a NIC unless that NIC happens to be on the same physical subnet as the server.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
Im creating a basic port scanning program that using multi threads to scan ports to serve as a way for me to learn Sockets and Threadpooling, but when i build the program and try to scan one port i get an exception error.
System.Net.Sockets.SocketException: The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for
at System.Net.Dns.GetHostByName(String hostName)
at System.Net.Dns.Resolve(String hostName)
at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port)
at PortScanner.frmportscanner.scanport(String host, Int32 port) in d:\csharp\ircbot\windowsapplication1\port scanner.cs:line 258
Any Suggestions?
|
|
|
|
|
Try using nslookup.exe in the command-prompt for the name you're trying to connect to and see what you get. The exception message indicates that the necessary data (perhaps an IPv4 address?) wasn't found.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I get that exception for every address i type in.
|
|
|
|
|
I have written a service that grabs the files in a source directory on a remote server and ftp's to local directory. The service monitors the source directory of the server and collects the files as they come in. The Problem: Sometimes the files are physically present but the service recognizes and at the time of transfer it cannot get handle on them. I gut feeling is - the service tries to grab the file when it is in the process of being tranferred to the source directory. It loses the handle on the file and can never recover thereafter. Any suggestions !
Thanks / Vinayak
|
|
|
|
|
The service should maintain a list of files it has tried to copy. If the copy is successful the file can be removed from the list, if not an attempt can be made on the next cycle when it looks for files again.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Thanks Colin.
I have an ftp component that returns the list of files in the source directory as a dataset. But once the file is failed to be tranferred via the Service Component - I go for the next one tranfer it.
When the service makes the next attempt - is gets the failed file
in the list but fails to transfer saying that "the file can not be found".
|
|
|
|
|
japanreddy wrote:
but fails to transfer saying that "the file can not be found".
Is the file physically there? Or in the first failed attempt did it remove the file? (Do you remove the files once they are transferred? If yes, could this be happening even if the file fails to transfer?)
Another, possible workaround is to build in a wait step before transferring the file. You see the new file for the first time, but you wait until the next cycle of the service before attempting to transfer it. As your FTP component returns the list of files as datasets, you could retain the previous dataset and compare it with the new dataset and transfer files that appear on both. BTW, how often do you check the directory for new files?
However, it would be better to find out why the files are failing to transfer and why on the second attempt the file is not found.
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
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Yes, the file is physically there, yet - the service cannot transfer it!
It did not remove the file on the first attempt. However, if the transfer
is successful, I am removing the file from the remote server.
Your next point is a valid one, that is about removing the file despite its failure to tranfer. I have blocked the code in two try blocks.
In the first try block I try to tranfer the file and remove only if
it is successful. Else do not enter the remove block.
I liked your approach to the problem. Thanks / Vinayak
|
|
|
|
|
Can someone share some Interop C# Code on how to check a word document for Linked OLE Document (typically PPT) and then change it's OLELink Path to a new local directory?
Thank you in advance.
|
|
|
|
|
i need the user to select a value from a datagrid and put that values into a textbox?
|
|
|
|
|
Even handling the WM_PARENTNOTIFY message won't work (it will receive the WM_LBUTTONDOWN message, but you can just as easily handle DataGrid.CurrentCellChanged ) because once the cell is in edit more, the hosted control is what is handling windows messages.
My recommendation is to just handle the DataGrid.CurrentCellChanged with a little logic to determine when the user is picking a cell (or may no additional logic is required).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yes it is a feature that i think many people have been asking for. the problem is i need the change to be immediate and the cellchanged is one step too late. I settled for the mouse down event it works a treat to increment the value in a textbox i am now working on an event to decrease the value and hopefully trap the right mouse button and use that to decrease the value. growing in confidence by the day!!!
|
|
|
|
|
fell flat on that idea it only fires the once help!!!
|
|
|
|
|
Hi,
I'm just asking your opinion for a design question. I'd like to present you some key facts about a quite complex application I just start working on. Important for me is the simplicity of the design. Performance or Complexity is not an issue. I just want to be able to understand the code even if a year has been going into the country.
1. The application is a based on a SQLDB. Some of the clients of this application are webbased and some are winforms applications. I'd like both of the client-types access something like a (or multiple) core.dll('s) which implement(s) all the logic and data-access stuff.
2. The application maintains users, usergroups and permissions. That is, each user belongs to a group and each group has certain permissions in terms of what it can do (what commands it can execute). A command might be something like "Create a new Project", "Print this" or "Enumerate this collection".
4. Commands, which are not available to the user (because he hasn't got sufficient privileges) should not be shown in the GUI (that is, if the User is not allowed to "Print this", he shouldn't have a menu-item in his Winforms GUI saying "Print this".
What makes me a headache at the moment is the question of how to design my classes. I'm dealing here with a lot of collections (Customers/Customer/Contacts/Contact, etc.) Basically i'd like to have a nice, clean and understandable object hierarchy.
If you feel you'd like to discuss this question (might be helpful to others as well) but you need further information, please let me know.
Thanks for reading,
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
1, 2 and 4 seem reasonable. (Is 3 AWOL?)
What do you mean by a "nice, clean and understandable object heirarchy"? Do you mean the way the classes relate to one another, the namespace that a class might sit in or what?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Colin Angus Mackay wrote:
1, 2 and 4 seem reasonable. (Is 3 AWOL?)
I don't know what AWOL is, but it has just gone down the road...
Colin Angus Mackay wrote:
What do you mean by a "nice, clean and understandable object heirarchy"? Do you mean the way the classes relate to one another, the namespace that a class might sit in or what?
I don't mean the namespaces, these classes might sit in. It's rather the way, classes relate to one another, eg.:
Say we have a root class (top-level), called DB_App, this class might then have a property allowing access to the Projects collection, which in turn might be used to access a Project instance which in turn has a property called ProjectServices (collection), and so on. Is this reasonable?
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
AWOL = Absent WithOut Leave
Yes, your suggestion seems reasonable. But, I find that object relations often closely map to the relationships in the database, so if your data model is heirarchical then it would follow that so will your class model be.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Colin Angus Mackay wrote:
Yes, your suggestion seems reasonable. But, I find that object relations often closely map to the relationships in the database, so if your data model is heirarchical then it would follow that so will your class model be.
Yes, for sure. But I'm more concerned about how to deal with the commands and the access to them. I imagine the db-design for the command type of things somewhat like this:
Database-Tables:
Commands (contains a record for each command, e.g. "View all projects"
UserGroups (self explanatory)
Users (self explanatory)
UserGroups_Commands (a table matchings those two. one column for the commandid and one for the usergroupid)
But how do I deal with it in the application? How to build the menus? Some commands might not be available through the menu. For example I have a Treeview in the application that allows to navigate the projects. For users which belong to groupA, all projects might be navigated. For those of groupB only a subset.
Any ideas?
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
First off, congratulations on your noble goals.
In the past, I have typically created what I think of as "heavy" business objects, which contain the queries used to persist them, properties that can be used to get related objects, validation, etc. I have found this design to be inflexible, and the objects can become overly complex. Better is to separate these into multiple classes, and let each one be simple, and do what it does well. (This also makes them easy to write).
For example, in my more recent projects, I have taken to splitting each business object into 2 separate parts. The first is for persisting and retrieving data, and does the object-relational db mapping. The second contains object properties, and not much else. Validation is coded outside of these objects, so as to be re-usable at different levels.
Thus, I might have 2 classes, Business.Customer and Data.Customer . To retrieve a customer from the database, I say something like MyCustomer = Data.Customer.GetById(customerId) .
If I want to retrieve the address of the Customer, I say MyCustomerAddress = Data.Address.GetById(MyCustomer.AddressId) (whereas before, I would say MyCustomerAddress = MyCustomer.Address) ). The old technique was a false economy, primarily because it created inflexibility while adding very little (I can still do it in a single line of code).
This works out great for me, and here's the clincher - the classes are all generated from the database, using a tool called CodeSmith. Once they are generated, I tweak them as needed. Mostly, I can then concentrate on the coding of my actual application, without worrying about SQL, etc.
IMO, "business" object design should be no harder than database design. Bang those together (preferably using tools), and then you can concentrate on the more challenging pieces, such as security, validation, and your controlling logic.
|
|
|
|
|
Hi Matthias,
Take a look at Martin Fowler's "Patterns Of Enterprise Application Architecture", it'll clean up your ideas.
As a quick suggestion I give the following:
BLL:
1) Organize your objects in Domain Logic, provide a Layer supertype (base object) for all of them
2) Create strongly typed collections for entities
3) Create business operations objects
DAL:
1) Create DACs (aka Data Mappers) for each entity object
2) Use DataSets (called Data Transfer Objects DTOs here) to pass data between DAL and BLL
Helper Layer:
Use metadata mapping (via Reflection) or XML represenation to convert data rows to business entities
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
I second that book recommendation.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Hi!
I am having an interesting problem while compiling code across different projects in the same VS.NET solution. Here is the scenario:
1. I have a project (called DataTypes) which defines common classes that I want to use throughout.
2. There is a webservice (WSA) which has a method which accepts two objects:
MethodA(DataTypes.Type1 objType1, DataTypes.Type2 objType2)
3. This webservice also calls another webservice (WSB) from MethodA. The method in WSB has the following signature: MethodB(DataTypes.Type1 objType1, DataTypes.Type2 objType2). In the WSA project there is a web reference to WSB (lets call it refB).
So this looks like:
MethodA(DataTypes.Type1 objType1, DataTypes.Type2 objType2){
objType1.somefield=new_value;
refB.MethodB(objType1, objType2);
}
When the client invokes WSA it passes the objects. MethodA modifies one of the parameters and passes these to WSB.
4. This code gives me a compilation error. The error message is "Cannot convert DataTypes.Type1 to refb.Type1". Understandably, the type information in the generated proxy for WSB refers to its interpretation of what Type1 is. Even though its the same as that in WSA.
Any suggestions on how I can solve this problem?
Thanks!
|
|
|
|
|
Hi,
I remember reading somewhere that when you pass an object to a webservice, it gets autoconverted to a proxy object, which _is not_ of the same type as the one being passed. That is the problem, imho.
It is recommended to pass DTOs (data transfer objects) between layer boundaries (which is, when you call a method in a web service, you pass the layer boundary).
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|