Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
chocojosh
Jun 9, 2007

D00D.

jwnin posted:

You should take a look at reflector http://www.aisto.com/roeder/dotnet/. He does what you seem to want to do, so while it doesn't solve your problem it should be doable by an independent party.

The tool is named appropriately, as it seems you want to go after Reflection: http://msdn2.microsoft.com/en-us/library/f7ykdhsy.aspx

Thank you!! After some browsing on the msdn, I found this article (http://msdn.microsoft.com/msdnmag/issues/06/03/TestRun/default.aspx) which provides a tool to analyze assembly dependencies and method dependencies. That was exactly what I needed (I'm working on making a tool to help my company analyze its source code).
(http://msdn.microsoft.com/msdnmag/issues/06/03/TestRun/default.aspx?loc=&fig=true#fig7)

The code to analyze method dependencies also happens to use an API provided by reflector ;)

Adbot
ADBOT LOVES YOU

Atimo
Feb 21, 2007
Lurking since '03
Fun Shoe

Atimo posted:

.... a bunch of crap ....

I found a solution finally! :hellyeah:

After you add the webservice you need to go back into the generated proxy and add the refrence to the common interface the generics will be using.

After that a little bit of reflection takes care of the rest!

code:
    public class ConnectToWebService<GenericInterface>
    {
        public GenericInterface GetService(string className)
        {
            System.Runtime.Remoting.ObjectHandle x = Activator.CreateInstanceFrom(System.Reflection.Assembly.GetExecutingAssembly().CodeBase, className);
            return ((GenericInterface)x.Unwrap());
        }
    }

Shayla
Nov 4, 2004
I have a class that I'm binding to a combobox on the compact framework.

code:
    public class PlotItem
    {
        private string _plotID;

        public string PlotID
        {
            get { return _plotID; }
            set { _plotID = value; }
        }
        private string _key;

        public string Key
        {
            get { return _key; }
            set { _key = value; }
        }
        private bool _isCompleted;

        public bool IsCompleted
        {
            get { return _isCompleted; }
            set { _isCompleted = value; }
        }

        public PlotItem()
        { }

        public PlotItem(string PlotID, string Key, bool IsCompleted)
        {
            _plotID = PlotID;
            _key = Key;
            _isCompleted = IsCompleted;
        }

        public override string ToString()
        {
            return _isCompleted ? "* " + _plotID : _plotID;
        }

    }
The problem is, when I change _isCompleted, the text doesn't change. It does work if it is set before the combobox is bound, though. How can I refresh the text?

Vedder
Jun 20, 2006

When you use the FileUploader is there anyway you can use network paths? I am creating a small application that transfers files to certain users desktops on request. A user who logs in as AS wants a certain file but the path to his desktop that works in explorer doesn't in ASP.NET.

I have a previous application where "C:\Test\file" works but I can't get the path to go to one like this: \\10.0.0.1\c$\Documents and Settings\AS\Desktop\

Is this even possible?

jwnin
Aug 3, 2003
You probably need to create an app pool with a certain identity (ex: domain\websvc), assign the web site to that app pool, and grant that account permissions to the share on the desktop. Don't use c$ because that requires the website to have administrative privileges to the desktops.

wwb
Aug 17, 2004

^^^Not really, that is a client-side issue, not a server-side issue methinks.

Are the users running vista?

Vedder
Jun 20, 2006

No, the workstations are XP.

chocojosh
Jun 9, 2007

D00D.

Ryuichi posted:

I have a class that I'm binding to a combobox on the compact framework.

code:
    public class PlotItem
    {
        private string _plotID;

        public string PlotID
        {
            get { return _plotID; }
            set { _plotID = value; }
        }
        private string _key;

        public string Key
        {
            get { return _key; }
            set { _key = value; }
        }
        private bool _isCompleted;

        public bool IsCompleted
        {
            get { return _isCompleted; }
            set { _isCompleted = value; }
        }

        public PlotItem()
        { }

        public PlotItem(string PlotID, string Key, bool IsCompleted)
        {
            _plotID = PlotID;
            _key = Key;
            _isCompleted = IsCompleted;
        }

        public override string ToString()
        {
            return _isCompleted ? "* " + _plotID : _plotID;
        }

    }
The problem is, when I change _isCompleted, the text doesn't change. It does work if it is set before the combobox is bound, though. How can I refresh the text?

I believe that's the default behaviour. If you change the text in the dataSource, then you need to recall DataBind()

Nurbs
Aug 31, 2001

Three fries short of a happy meal...Whacko!
I have a small asp.net webform that is feeding into a sqlserver 2005 database.

Besides using a parameterized query and putting my connectionstring in the web.config file are there any other security measures I should be taking?

wwb
Aug 17, 2004

Only other big one is to make sure your database user is running with the least possible permissions rather than DBO or sysadmin priviliges.

Nurbs
Aug 31, 2001

Three fries short of a happy meal...Whacko!

wwb posted:

Only other big one is to make sure your database user is running with the least possible permissions rather than DBO or sysadmin priviliges.

Then I'm good to go. Thanks

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!
Why is it that the default "root" directory of my projects is always C:\Windows\System32 instead of, you know, the root of the project?

Is there some kind of setting thing that I'm loving up or is there a way to get around that, or is it inherant in .NET or something?

Fastbreak
Jul 4, 2002
Don't worry, I had ten bucks.

Myrddin Emrys posted:

Why is it that the default "root" directory of my projects is always C:\Windows\System32 instead of, you know, the root of the project?

Is there some kind of setting thing that I'm loving up or is there a way to get around that, or is it inherant in .NET or something?

Thats where the framework is based, so all the classes from the framework will be running from there. Try using current directory, I think thats the one that worked for me.

I don't really have an issue, but just wondering how some of the other .Net gurus would go about this. I am trying to write a wrapper class for an xml that I will be posting to a webservice. How it will really work is that I will take in all this information from a webform, load it into said class, and the post that data into xml form to the webservice.

I generated a class based off of an xsd and it works, but I am wondering if someone can suggest a more elegant solution.

Fastbreak fucked around with this message at 21:47 on Oct 11, 2007

havelock
Jan 20, 2004

IGNORE ME
Soiled Meat

Fastbreak posted:

Thats where the framework is based, so all the classes from the framework will be running from there. Try using current directory, I think thats the one that worked for me.

I don't really have an issue, but just wondering how some of the other .Net gurus would go about this. I am trying to write a wrapper class for an xml that I will be posting to a webservice. How it will really work is that I will take in all this information from a webform, load it into said class, and the post that data into xml form to the webservice.

I generated a class based off of an xsd and it works, but I am wondering if someone can suggest a more elegant solution.

Add a web reference to the web service so you don't have to do the XML stuff yourself? You can use the strongly generated proxy and call the service as if it were a method. Or are you asking something else?

Nurbs
Aug 31, 2001

Three fries short of a happy meal...Whacko!
Has anyone ever worked with sending emails from a .NET program?

I'm using System.Net.Mail and an smtp client configured in my web.config with my account info on the mailserver I use.

Messages will get sent so long as the recipient has a mailbox on my mailserver, but I'll get a relay error if they need to go anywhere else. What do I need to do?

biznatchio
Mar 31, 2001


Buglord

Nurbs posted:

Messages will get sent so long as the recipient has a mailbox on my mailserver, but I'll get a relay error if they need to go anywhere else. What do I need to do?

You need to configure your mail server to allow relaying (be very careful, being too liberal in relay settings and your mail server will be taken over by spammers).

Nurbs
Aug 31, 2001

Three fries short of a happy meal...Whacko!

biznatchio posted:

You need to configure your mail server to allow relaying (be very careful, being too liberal in relay settings and your mail server will be taken over by spammers).

I kind of guessed that, but I guess my question is why its not sent as if I send it from outlook - I'm just curious to know how the mailserver makes the distinction.

(Let's also pretend the server is out of my jurisdiction and my request for having the proper relay settings won't get approved, what are my alternatives?)

Nurbs fucked around with this message at 04:09 on Oct 13, 2007

poopiehead
Oct 6, 2004

Nurbs posted:

I kind of guessed that, but I guess my question is why its not sent as if I send it from outlook - I'm just curious to know how the mailserver makes the distinction.

(Let's also pretend the server is out of my jurisdiction and my request for having the proper relay settings won't get approved, what are my alternatives?)

I'm assuming you're talking about exchange server. I'm pretty sure(though I can be wrong) that outlook talks to exchange server through a protocol other than smtp, so you're using a different method than outlook does. I'm not sure if there are any APIs to talk to directly to exchange server's protocol earlier than exchange server 2007. It looks like 2007 has an API based on web services that might work, specifically the SendItem Method

ljw1004
Jan 18, 2005

rum

Nurbs posted:

I kind of guessed that, but I guess my question is why its not sent as if I send it from outlook - I'm just curious to know how the mailserver makes the distinction.

Outlook (the UI that you see) is just a MAPI client. It connects to several MAPI servers -- e.g. the MAPI PST server, which is a DLL that sits on your computer and lets MAPI clients interact with PST personal message stores. Also the MAPI Exchange server, which is a DLL that sits on your computer and lets MAPI clients interact with Exchange servers over the internet. Also the MAPI imap/smtp server, which is a DLL that sits on your computer and lets MAPI clients interact with IMAP/SMTP servers over the internet.

Users won't have MAPI on their computer unless they installed Outlook.

I bet that when you fire up Outlook, it's talking to a mailserver on a remote machine, not to the one on your local machine.

If you wanted to send mails the same way that Outlook does, you could program interact with MAPI directly (that's hard) or with CDO (which is a fair bit cleaner but I don't know how it works with .net).

The whole point of System.Net.Mail, as I understand it, was to give email functionality to .net programs even on computers that don't have Outlook installed on them. That's why it doesn't use MAPI at all. Instead it communicates directly with an SMTP server.

Nurbs
Aug 31, 2001

Three fries short of a happy meal...Whacko!

ljw1004 posted:

words

Awesome, thanks!

fankey
Aug 31, 2001

I need to convert between System::Strings and UTF-8 encoded std::strings. The following appears to work but I'm not sure if it's correct and if it's the most efficient way. Any comments?
code:
std::string UTF16toUTF8( System::String^ s )
{
  System::Text::Encoding^ UTF8enc= System::Text::Encoding::UTF8;
  array<unsigned char>^ UTF8bytes = UTF8enc->GetBytes(s);
  int UTF8len = UTF8bytes->Length;
  IntPtr ptr = Marshal::AllocHGlobal(UTF8len);
  Marshal::Copy(UTF8bytes, 0, ptr, UTF8len);
  if(ptr != IntPtr::Zero)
  {
    std::string UTF8str = std::string((const char*)ptr.ToPointer(), UTF8len);
    Marshal::FreeHGlobal(ptr);
    return UTF8str;
  }
  return std::string();
}

System::String^ UTF8toUTF16( const std::string& s )
{
  System::Text::Encoding^ UTF8enc = System::Text::Encoding::UTF8;
  IntPtr ptr(reinterpret_cast<void*>(const_cast<char*>(s.c_str())));
  array<unsigned char>^ UTF8bytes = gcnew array<unsigned char>(s.length());
  Marshal::Copy(ptr, UTF8bytes, 0, s.length());
  return UTF8enc->GetString(UTF8bytes);
}

csammis
Aug 26, 2003

Mental Institution

fankey posted:

I need to convert between System::Strings and UTF-8 encoded std::strings. The following appears to work but I'm not sure if it's correct and if it's the most efficient way. Any comments?
code:

System::String^ UTF8toUTF16( const std::string& s )
{
  System::Text::Encoding^ UTF8enc = System::Text::Encoding::UTF8;
  IntPtr ptr(reinterpret_cast<void*>(const_cast<char*>(s.c_str())));
  array<unsigned char>^ UTF8bytes = gcnew array<unsigned char>([b]s.length()[/b]);
  Marshal::Copy(ptr, UTF8bytes, 0, [b]s.length()[/b]);
  return UTF8enc->GetString(UTF8bytes);
}

I don't think you can rely on s.length() to calculate the number of bytes to allocate and copy, since one character could be encoded by multiple bytes in UTF-8. That's what Encoding::GetByteCount() is for.

ljw1004
Jan 18, 2005

rum

fankey posted:

I need to convert between System::Strings and UTF-8 encoded std::strings. The following appears to work but I'm not sure if it's correct and if it's the most efficient way.

I wonder if there's a neater way to do it using pin_ptr instead of marshalling?

fankey
Aug 31, 2001

csammis posted:

I don't think you can rely on s.length() to calculate the number of bytes to allocate and copy, since one character could be encoded by multiple bytes in UTF-8. That's what Encoding::GetByteCount() is for.
It was my understanding that Encoding::GetByteCount returns the number of bytes required to represent a .Net string in that particular encoding. In this case I'm going the other way - my string is raw UTF8 ( which should be guaranteed not to have any embedded nulls ) so string.length() should return the number of bytes in the UTF8 stream.

ljw1004 posted:

I wonder if there's a neater way to do it using pin_ptr instead of marshalling?
I quick google looks like I might be able to use it for the managed->unmanaged call. I'll see if I can figure that out.

Update : This appears to work. Not sure if there's a way to use this for the unmanaged->managed call.
code:
std::string UTF16toUTF8( System::String^ s )
{
  System::Text::Encoding^ UTF8enc= System::Text::Encoding::UTF8;
  array<unsigned char>^ UTF8bytes = UTF8enc->GetBytes(s);
  if( UTF8bytes->Length )
  {
    pin_ptr<unsigned char> p = &UTF8bytes[0];
    return std::string((char*)p,UTF8bytes->Length);
  }
  return std::string();
}

fankey fucked around with this message at 22:21 on Oct 15, 2007

csammis
Aug 26, 2003

Mental Institution

fankey posted:

It was my understanding that Encoding::GetByteCount returns the number of bytes required to represent a .Net string in that particular encoding. In this case I'm going the other way - my string is raw UTF8 ( which should be guaranteed not to have any embedded nulls ) so string.length() should return the number of bytes in the UTF8 stream.

No, it returns the number of non-null characters, which on Windows could be w_char and thus 16-bit (two bytes). char and byte aren't necessarily interchangable.

ref:

quote:

Be aware that UTF-8 uses more than one byte for extended characters, so std::string::length() might not reflect the actual length of the string if it contains any non-ASCII characters.

edit: In fact, the code on that page basically solves your problem, doesn't it?

csammis fucked around with this message at 22:27 on Oct 15, 2007

fankey
Aug 31, 2001

csammis posted:

No, it returns the number of non-null characters, which on Windows could be w_char and thus 16-bit (two bytes). char and byte aren't necessarily interchangable.

ref:

Say I pass in the following single character э, which is represented by 2 bytes 0x04 and 0x4d. s.length will return 2 - the number of bytes in the string. I then want to marshal that to a 2 byte managed array. The string I end up returning will be 1 character but that's taken care of by the GetString() call. I don't see why my code should care about character count.
code:
System::String^ UTF8toUTF16( const std::string& s )
{
  System::Text::Encoding^ UTF8enc = System::Text::Encoding::UTF8;
  IntPtr ptr(reinterpret_cast<void*>(const_cast<char*>(s.c_str())));
  // s.length() returns 2 here
  // UTF8bytes should be 2 as well
  array<unsigned char>^ UTF8bytes = gcnew array<unsigned char>(s.length());
  Marshal::Copy(ptr, UTF8bytes, 0, s.length());
  // this will return a string of 1 character - I really don't care how many bytes it requires.
  return UTF8enc->GetString(UTF8bytes);
}
That said, the page you posted looks like a better solution than rolling my own. Thanks for the link.

This code, taken from the page you posted, is doing the same thing I am ( arguably a little safer - they're not assuming that std::string::value_type is 1 byte ). And it looks like you can use pin_ptr to go unmanaged->managed anyways.
code:
        size_t byteCount = cxxString.length() * sizeof(SourceType::value_type);

        // Copy the C++ string contents into a managed array of bytes
        array<unsigned char> ^bytes = gcnew array<unsigned char>(byteCount);
        { pin_ptr<unsigned char> nativeBytes = &bytes[0];
          memcpy(nativeBytes, cxxString.c_str(), byteCount);
        }
Update 2 : A Warning!
FYI, if you are using that code, it crashes if you send it a 0 length std::string
code:
pin_ptr<unsigned char> nativeBytes(&bytes[0]);

fankey fucked around with this message at 23:16 on Oct 15, 2007

Mackin
Jan 14, 2001

Fun (pain) with IStream and COM interop.

I have a COM library that I wrote, let's call it ComLib, with a method that takes an IStream as one of the arguments. I want to call this method from C#, passing in a C# class I wrote that implements InteropServices.ComTypes.IStream.

The COM method signature in C# looks like this:
code:
void Class.Method(ComLib.IStream stream)
and casting my .Net class to ComLib.IStream causes an invalid cast runtime error.

I tried implementing ComLib.IStream instead of InteropServices.ComTypes.IStream, and that time I got a "Class not registered" runtime error when I called the method. Update: the "Class not registered" error was caused by unrelated code, and I can in fact get this to work by implementing ComLib.IStream, I'd just rather implement InteropServices.IStream, for reasons below.

What's going on here? I have another method that returns an IPictureDisp, and .Net recognizes it as an stdole.IPictureDisp just fine. Why does .Net think that IStream is defined inside my own library, while it correctly identifies IPictureDisp as belonging to stdole?

I'd much rather implement InteropServices.IStream than ComLib.IStream. The InteropServices IStream has method signatures like this:
code:
public void Read(byte[] pv, int cb, IntPtr pcbRead)
while the equivalent method in ComLib.IStream is
code:
public void RemoteRead(out byte pv, uint cb, out uint pcbRead)
and I'm not really sure how to treat an out byte as a byte array. Maybe using unsafe and getting a pointer to it? I can't test this because I can't actually call the method. I don't understand why the method name is different either, but I'm pretty sure that's the least of my problems. Help.

Update: implementing ComLib.IStream works, as does using an unsafe block to read and write from the "out byte pv" argument as an array. I'm still confused about why .Net doesn't recognize IStream correctly.

Mackin fucked around with this message at 20:57 on Oct 16, 2007

Dude Koz
Dec 8, 2004
Women have nice parts.
I have a TaskBar application which has several Items in its main menu. One of those items requires activation, so when I click on it, my app prompts the user for a password. Upon a successful login, I build a ContextMenuStrip which gets populated with items, and set to that original item's DropDown property.

Well, I actually redraw the main menu upon opening (in order to maintain some order) The problem is that my app doesn't appear to recognize the new Sub-Menu I created, at least until you hover over that original item, then all of a sudden it recognizes the menu, and displays the characteristic ">" next to the name. Clearly something is 'updating' on the MouseEnter event handler.

I wouldn't normally care, but when that happens, the new menu won't actually open until the mouse comes off of the item, and then back on again, which is extremely annoying. However, it only happens the first time...after that it remains correct.

I've tried refreshing and/or invalidating just about everything before opening, to no avail. Is there anything I'm missing that will help alleviate my problem? I am thinking this is a "lazy load" type issue, but I'm not sure.

Thanks!

biznatchio
Mar 31, 2001


Buglord

Dude Koz posted:

I have a TaskBar application which has several Items in its main menu. One of those items requires activation, so when I click on it, my app prompts the user for a password. Upon a successful login, I build a ContextMenuStrip which gets populated with items, and set to that original item's DropDown property.

Try adding the menu items directly to the parent menu's DropDown property; not to a ContextMenuStrip that is then assigned to it. DropDown is a collection that's intended to hold the sub items.

Dude Koz
Dec 8, 2004
Women have nice parts.

biznatchio posted:

Try adding the menu items directly to the parent menu's DropDown property; not to a ContextMenuStrip that is then assigned to it. DropDown is a collection that's intended to hold the sub items.

Normally I would do exactly as you said, but the Sub Menu is controlled by a Plugin, so I cannot add directly to the drop down. The plugin is an interface with a context menu property. Every plugin gets an item in the main menu (controlled by the framework) and then that item gets a dropdown set equal to the ContextMenuStrip of the IPlugin.

Thanks.

MrPhred
Feb 27, 2004

I MASTURBATED ALL DAY TO THIS PICTURE OF GWB. SEMEN MAKES MY KEYBOARD STICKY OH SHI
Sorry for the newbish question, and it might have been answered already, but I don't have time to read through 37 pages of posts. I did try Google and Wikipedia first though.

I'm trying to do a fresh install of Windows XP Pro SP2 on my Thinkpad. I'm using nLite to remove components. I will probably mark the .NET Framework for removal as I will inevitably have to install the most recent version post install anyways (I think). Maybe this is a bad idea. Maybe a good one. I don't know.

Anyway, I'm trying to figure out what I need to download for .NET Support. I was looking at RyanVMs page and he has a couple of switchless installers posted. The one I was looking at says that it contains .NET 1.1, .NET 3.0, and VC8 SP1 Redistributable (I don't even know what that last one is). I probably won't use the switchless installer though and just install it myself after I finish installing XP.
What do I need to have an up to date .NET framework for Windows XP SP2 (with all the most recent hotfixes already installed)?

Edit: I found out that VC is Visual C++. Do I need that as well? How is that related to the .NET Framework?

Edit Edit: Here's the websites I'm thinking are the most up to date for both. Is this all I need?

VC8 SP1 Redistributable:
http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647&DisplayLang=en

.NET Framework 3.0
http://www.microsoft.com/downloads/details.aspx?familyid=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=en

MrPhred fucked around with this message at 00:59 on Oct 20, 2007

Biscuit Hider
Apr 12, 2005

Biscuit Hider
Hey guys...this is probably a freaking retarded question, but here goes.

At my office, we have been using NHibernate for so long that going back to ADO.Net is like a foreign thing to me now. Have things progressed in that area much? Or is everyone just pretty much using something new now?

Do most people still use ADO.Net? Do most people use strongly typed data sets? Are most people using O/R mapping tools?

Please pardon the retardation of this post, I just feel extremely outdated.

The Noble Nobbler
Jul 14, 2003

Hybridfusion posted:

Hey guys...this is probably a freaking retarded question, but here goes.

At my office, we have been using NHibernate for so long that going back to ADO.Net is like a foreign thing to me now. Have things progressed in that area much? Or is everyone just pretty much using something new now?

Do most people still use ADO.Net? Do most people use strongly typed data sets? Are most people using O/R mapping tools?

Please pardon the retardation of this post, I just feel extremely outdated.

No, those are all very simple but good questions -- where I work, we code enterprise level cash and workforce management solutions, all using homemade objects for their flexibility. It takes longer, but in the end, it beats getting so married to an O/R solution that a problem with it causes just the kind of headache you were looking to avoid.

We aren't a fan of typed datasets, and I absolutely hate the MS solutions for managing datasets.

Casimirus
Mar 28, 2005
Yes.
Does anyone know of a way to get/set the state of numlock, capslock, and scrolllock without importing user32.dll?

If I do import user32.dll for whichever functions I need (also any tips here?), am I guaranteed that my code will work with any reasonable version of Windows(2k+)? I ask because I am developing on XP 64 bit, and I would hate to have this not work in other places.

wwb
Aug 17, 2004

Hybridfusion posted:

A non-retarded question.

We use a variety of solutions depending on nature of the application. The large, industrial strength stuff flies off a home-brewed quasi ORM solution, largely for the same reasons lightbulbsun states. Biggest kicker is that most of the new, neato, augo-generated ORM solutions pretty much demand a 1-to-1 mapping of db to public properties, which might not make sense in some scenarios.

For lighter-weight stuff which is not quite so long-standing, we have started to use SubSonic. It is a very, very nifty solution. We are actually contemplating ripping out the ADO.NET bits of the home-brewed stuff and using SubSonic to manage the mechanical angles of persistence.

MS' new hawtness is LINQ. Which looks real neat, but I don't think it is quite ready for significant applications. See Rick Strahl's blog for some interesting 'features' he has found. More promising is the upcoming Entity Framework, which looks to be a very slick nHibernate killer.

I cannot claim to have ever used a Typed Dataset outside of a classroom scenario. We use DataSets internally in our homebrew framework--sometimes it is alot more efficent to load multiple tables in one hit. But they definitely don't ever get passed outside of the data tier.

csammis
Aug 26, 2003

Mental Institution

Casimirus posted:

Does anyone know of a way to get/set the state of numlock, capslock, and scrolllock without importing user32.dll?

If I do import user32.dll for whichever functions I need (also any tips here?), am I guaranteed that my code will work with any reasonable version of Windows(2k+)? I ask because I am developing on XP 64 bit, and I would hate to have this not work in other places.

Getting, you can use this class from the Microsoft.VisualBasic library. Yes, it will work if you're using C#, but it won't work if you want to set the state.

As for the rest of your question, Get/SetKeyboardState are supported from Windows 95 and Windows NT 3.1 and up. This can be found in the MSDN documentation for the functions under Function Information.

Biscuit Hider
Apr 12, 2005

Biscuit Hider
So it sounds like everyone just kinda does their own thing. SubSonic looks freaking awesome and I may start to play around with that tonight.

Good to hear that plain old ADO.Net is still popular, I am glad I am not light years behind like I thought I was.

uh zip zoom
May 28, 2003

Sensitive Thugs Need Hugs

can one of you C# gurus tell me why this code isn't working?

this code is from my global.asax file, and it's supposed to hook up the event to the timer when the application starts, then set the interval to a value stored in web.config, then execute the event once.

Edit: the problem is the timer. ActiveUplidCount is supposed to be updating on an interval set by that value stored in web.config, but when I set that value to something really short, it doesn't update

Let me know if you guys need more information about the situation

code:
    private static System.Timers.Timer aTimer = new System.Timers.Timer();
  
    void Application_Start(object sender, EventArgs e) 
    {
		
      
      aTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
      
      SetIntervalTimer(Convert.ToInt32(WebConfigurationManager.AppSettings["UpdateAccessPointInterval"]));
      SetAccessPointCount();
    }
  
    private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
    {
       SetAccessPointCount();
    }

    private static void SetAccessPointCount()
    {
      try
      {
        int ActiveUplidCount = 0;
        Dentemax.PortalData.NetworkStats ns = new Dentemax.PortalData.NetworkStats();
        ActiveUplidCount = ns.GetActiveUplidCount();
        WebConfigurationManager.AppSettings["AccessPointCount"] = ActiveUplidCount.ToString("N0");
      }
      catch
      {
        SetIntervalTimer(15);
      }
    }

    private static void SetIntervalTimer(int IntervalInMinutes)
    {
      aTimer.Interval = ((IntervalInMinutes * 60) * 1000);
      aTimer.Enabled = true;
    } 

uh zip zoom fucked around with this message at 20:09 on Oct 21, 2007

csammis
Aug 26, 2003

Mental Institution

uh zip zoom posted:

Edit: the problem is the timer. ActiveUplidCount is supposed to be updating on an interval set by that value stored in web.config, but when I set that value to something really short, it doesn't update

How really short?

Adbot
ADBOT LOVES YOU

uXs
May 3, 2005

Mark it zero!

wwb posted:

We use a variety of solutions depending on nature of the application. The large, industrial strength stuff flies off a home-brewed quasi ORM solution, largely for the same reasons lightbulbsun states. Biggest kicker is that most of the new, neato, augo-generated ORM solutions pretty much demand a 1-to-1 mapping of db to public properties, which might not make sense in some scenarios.

For lighter-weight stuff which is not quite so long-standing, we have started to use SubSonic. It is a very, very nifty solution. We are actually contemplating ripping out the ADO.NET bits of the home-brewed stuff and using SubSonic to manage the mechanical angles of persistence.

MS' new hawtness is LINQ. Which looks real neat, but I don't think it is quite ready for significant applications. See Rick Strahl's blog for some interesting 'features' he has found. More promising is the upcoming Entity Framework, which looks to be a very slick nHibernate killer.

I cannot claim to have ever used a Typed Dataset outside of a classroom scenario. We use DataSets internally in our homebrew framework--sometimes it is alot more efficent to load multiple tables in one hit. But they definitely don't ever get passed outside of the data tier.

I used datasets when I started out with .NET because it seemed like the obvious solution. Lately we've been using objects to pass data around with, and I like it a lot. I still use datasets in the latest project though, to be able to bind them to datagrids for very quick and dirty reporting. They're also easy to export to Excel for example. Using objects for that would be a lot slower to write. With datasets it's just basically writing a query, putting it in a dataset, and binding it to a grid.

  • Locked thread