Jump to content
Xtreme .Net Talk

joe_pool_is

Avatar/Signature
  • Posts

    512
  • Joined

  • Last visited

Everything posted by joe_pool_is

  1. This is on Visual C# 2005 Express. When I tried 'DefaultNamespace.Properties.Resources.ResourceName', I was able to debug down to the fact that the Resources.Designer.cs file had populated itself with [CS]internal static string mylogo { get { return ResourceManager.GetString("mylogo", resourceCulture); } } [/CS]Now, every time I try to delete that resource through the Resource Designer, C# stops responding. Grrrr!! Maybe I should just go home a little early for the day, huh?
  2. In my C# Project, I have added a couple hundred images by "drag-n-drop"-ing them into to the Properties.Resources section. All of these images were in an "images" folder of my Project on my computer. Currently, the Solution Explorer displays all of these images in an "images" folder that it created after my "drag-n-drop" operation. Now: How do I *get* these images for my code? I have a PictureBox named "pbImage" on my main form that needs to display these at various times, but my call to GetManifestResourceStream() always returns null. I am concerned that the string "imageName" may not be correct, but I can not seem to find the wording that C# is looking for. private void Set_Image(String imageName) { Assembly gExe = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream gImage; String[] name = gExe.GetManifestResourceNames(); String image = name[0] + "." + imageName; gExe = System.Reflection.Assembly.GetExecutingAssembly(); try { gImage = gExe.GetManifestResourceStream(image); // returns null pbImage.Image = Image.FromStream(gImage); // causes exception } catch (Exception ex) { Console.WriteLine("Exception Message: {0}", ex.Message); } } Any ideas?
  3. What about the special character '\'? In C++, it needs to be preceded by a special character '\'. So, your string would look like, "C:\\Program Files\\Sybase\\SQL ..." Not sure what language you are in; hope that helps.
  4. Sounds like what I want. Could you (or someone) throw me some tips that would let me get started fast with embedded resources? The majority of our products are still Borland creations, so we are a little slow when it comes to Visual Studio. Thanks for your help!
  5. How could I guarantee that the multiple images in my C# project are the ones that are supposed to be in there? Our company has an application that is being developed for use in a small, hand held device (palm pilot, etc). The application uses pictures to help the technician troubleshoot problems out in the field and details where to make connections, what bolts to tighten, etc. The company wants to safeguard the images used by the application to ensure no one can tamper with them, since a wrong image could result in injury or death. WiFi is not always available, especially deep in the coal mines or out on off-shore drilling platforms, so connecting to an SQL Server for our images is not the best idea. I tried embedding the images by using an image list, but then I am limited to 256 width by 256 height. We'd like our techs to be able to zoom in on a region if it is necessary. Regards, jp
  6. Ah! Old book on .NET. Apparently, now you don't have to include the List1.Item[int i] when itterating through a list. Just use List1[int i]. False alarm. Stand down, get back to work, or whatever you do. :)
  7. List<T> does not have an Item() method? You have got to be kidding me? After I get my hundreds of objects added to my new List, how am I expected to access them?
  8. The company populates innerHTML elements with these images which switch back and forth when Customers mouse over different links. The problem comes when the Customer clicks the link to pull up the information on that particular item, because the JavaScript wants to reload all of the images. That's what I was told, and I've been asked to fix it. If you know of a particular way to tell JavaScript to load an image from cache instead of downloading it, please enlighten me! Browsers are *supposed* to do this, but it doesn't often happen. Is there a way I could load all the images into a separate file and have that file remain loaded for the duration? For example, what if I turned their site into something that used frames, and loaded all of the images in the main form? Would there be a way for the Child pages to access images from the Parent frame? Then, when a Customer clicked a link associated with an image in an innerHTML document, the page could reload, but still know that the images are already sitting there waiting for them in the Parent. I don't know how to access an image on the Parent form, though, and I'm not sure how I'd put the images on the Parent form if the Parent form didn't really have a body tag. I'm just trying to brainstorm some ideas, and so far that is the best I've come up with.
  9. The images are physical files on the server disk. In its current configuration, the "developer" (a graphics artist) loaded all of the images using JavaScript (i.e. pic5 = new Image(); pic5.src = "images/map5.jpg"). The problem with this is that JavaScript isn't smart enough to realize that those images are already cached ...or so it seems. Therefore, anytime the page is refreshed, the JavaScript reloads all of the images. I've been asked to find a way to improve upon the graphics artist's code, but since I do not use ASP.NET, JavaScript, or HTML as often as I use C++, I'm not sure what the best approach would be. I believe a test for "IsPostBack" would work on ASP.NET systems, but is there something similar in Classic ASP or for JavaScript? The company might frown upon my solution were for them to migrate to ASP.NET servers.
  10. I've got a website I am building that includes several large images. Is there a way that I could store those images when the page initially loads, then reuse this info to populate places on my various different pages as they are loaded? A simple example would be nice, also.
  11. Sorry PlausiblyDamp, but I just was not able to make that work. Maybe it did not explain enough to me. I already had those settings defined in the project's Properties segment, but I did not know how to access them via the program (i.e. read/write the data with C#).
  12. Microsoft has a new Settings field in Visual Studio 2005 which can be accessed at design time via "Project | <Project Name> Properties..." item on the menu bar. I have successfully created the Settings fields for my project, but I need to read/write values for the user.config file using these settings at run time. I found an article on how to do it here: http://msdn2.microsoft.com/en-us/library/shytyc55.aspx but it seems to only be accessible via the "My" keyword, which is not part of the C# language. Does anyone know the proper way to access this information using C# on 2005?
  13. Mister E, For a simple lesson in learning C# features, I decided to create a simple calendar making program. It has 16 textboxes which determine the paths to photos for 12 months, plus 2 previous months and 2 months for the next year. When I save someone's project, I want to be able to save these paths as well. When I created my calendar class, I gave it a private string[16] path declaration along with a couple of public members to get/set values: Index and Path. To save the settings, I first have to set the Index, then set the Path: [system.Configuration.UserScopedSetting()] public string Path { get { return m_path[m_index]; } set { s_path[m_index] = value; } }Is there a way to save all of my 16 strings, or will this technique only save the last string that I accessed?
  14. Quick note: I found some info on accessing the Project Settings, but they all refer to My.Settings, and (in C# at least) there is no keyword My defined.
  15. I've been trying to find a way to save the settings of projects that clients' create with my C# projects. They can set page orientations, set paths, windows positions, etc. All these values are stored in my running application using a class called ThisProject that encapsulates the settings: ThisProject objProj = new ThisProject(); What are good, accepted methods of saving information like this? * I have found information on Serializing, but this seems to be set up for writing text files. * I noticed the Project > Properties has a Settings tab, but I can't find much info on what this is meant to save, where it is saved, how to write to it or retrieve it during code. I'm trying to familiarize myself with C# during my time off (until Jan 3rd). I've used only VB.NET (2002) and C++ in the past, so learning C# seems like a great idea!
  16. I'm trying to create some properties in my C# project, but the IDE (Visual Studio 2005 Express) is very upset and is throwing red squiggle lines underneath items everywhere. I realize the calendar class I am creating is probably done somewhere already, but I want to learn how to do some things with C# during my time off from work (where we are stuck using Borland). Right now, I want to find out how to add a property and how to access indexed property values. // ---------------------------------------- public class Calendoo { private string mName = "blank"; private string[] mMonth = new string[16]; private bool[] mInUse = new bool[16]; public string Name { get { return mName; } set { mName = value; } } public string MonthO(int i) { get { return mMonth[i]; } set { mMonth[i] = value; } } public bool UseO(int i) { get { return mInUse[i]; } set { mInUse[i] = value; } } } // ---------------------------------------- First off, when I hand type in the get/set values, the IDE throws a red squiggle beneath the { and says ; expected. Second, if I hadn't looked at the examples, I would not have known about the secret "value" variable. What would I modify if I wanted to change that to something else (like val, v, or Fred)? Third, the gets mad when I pass values into it, like (int i). How should this be done?
  17. So far, the error has only occurred the one time, but I haven't done extensive debugging on it. It is in managed C# code. If there is a preferred method of reading/writing registry keys, I'd certainly like to know. I'd like to be able to test for the keys on load and on create. For OnLoad: 1. create a key and initialize it. 2. if key exists (not null), 3. read values 4. else 5. set defaults 6. delete the key (well, that would be for "unmanaged code" like c++) For OnClose 1. create a key and initialize it. 2. try 3. write values 4. catch and throw away any errors 5. delete the key for "unmanaged code" But I want to make sure I have something robust that isn't going to create a bug that is going to terrorize or harass me. Here is what I am using in C#: [color=#0000ff]private [/color][color=#0000ff]void[/color] RegistryWork([color=#0000ff]bool[/color] bIn) { [color=#0000ff]try[/color] { [color=#008000]// HKEY_CURRENT_USER\Software\poojo.com\program[/color] Microsoft.Win32.[color=#008080]RegistryKey[/color] rkSoftware; rkSoftware = Microsoft.Win32.[color=#008080]Registry[/color].CurrentUser.CreateSubKey([color=#800000]"Software"[/color]); Microsoft.Win32.[color=#008080]RegistryKey[/color] rkCompany = rkSoftware.CreateSubKey([color=#800000]"poojo.com"[/color]); Microsoft.Win32.[color=#008080]RegistryKey[/color] rkProgram = rkCompany.CreateSubKey(program); [color=#0000ff]if[/color] (bIn == [color=#0000ff]true[/color]) { rkProgram.SetValue([color=#800000]"Folder"[/color], folder, Microsoft.Win32.[color=#008080]RegistryValueKind[/color].String); rkProgram.SetValue([color=#800000]"Common"[/color], common, Microsoft.Win32.[color=#008080]RegistryValueKind[/color].String); rkProgram.SetValue([color=#800000]"Local"[/color], local, Microsoft.Win32.[color=#008080]RegistryValueKind[/color].String); } [color=#0000ff]else[/color] { folder = ([color=#008080]String[/color])rkProgram.GetValue([color=#800000]"Folder"[/color], folder); } } [color=#0000ff]catch[/color] ([color=#008080]Exception[/color] ex) { [color=#008080]MessageBox[/color].Show([color=#800000]"Unable to use registry.\n"[/color] + ex.Message, [color=#800000]"Registry"[/color], [color=#008080]MessageBoxButtons[/color].OK); } }
  18. Really? It was my understanding that CreateSubKey() only created the key if it did not exist. Is there a preferred technique I should be using?
  19. I got this message today while debugging through a very small program using Visual Studio 2005 Express with my C# program: ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from COM context 0x1b11b8 to COM context 0x1b1328 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations. Is this something that I could have caused in my simple application? (All it does is fools around with registry settings, learning how to use different tools like the commonDialog in C# 2005, etc.) I was stepping over this piece of code when the debugger froze. // String folder // = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); private void RegistryWork(bool bIn) { String program = System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath); try { // HKEY_CURRENT_USER\Software\poojo.com\program Microsoft.Win32.RegistryKey rkSoftware; rkSoftware = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software"); Microsoft.Win32.RegistryKey rkCompany = rkSoftware.CreateSubKey("poojo.com"); Microsoft.Win32.RegistryKey rkProgram = rkCompany.CreateSubKey(program); if (bIn == true) { rkProgram.GetValue("Folder", folder); } else { rkProgram.SetValue("Folder", folder, Microsoft.Win32.RegistryValueKind.String); } } catch (Exception ex) { MessageBox.Show("Unable to use registry.\n" + ex.Message, "Registry", MessageBoxButtons.OK); } }It froze on the statement if (bIn == true)Why? Did I do something, or was this something caused by some other Microsoft thing running in the background? This has only happened once; I have not been able to reproduce it.
  20. Fabulous! Thanks. I was just looking into the thread "Implementing the IActiveDesktop in VB.NET" in the tutorial section, and it is very long! I'll look into your version first.
  21. There is a C++ function that I have used in Borland called SHGetSpecialFolderLocation that is actually a Microsoft API call. I'm looking for something similar to this in C#. Does it exist? Can I still use C++ APIs in C#?
  22. I'd rather keep it a per user password, whereas Dial-Up Networking is system wide. If I could find out how Dial-Up Networking stores its passwords, I would feel relatively safe using the same techniques on a per user basis. Right now, I'm storing it in the Registry as binary. If someone cares, it is easy to crack. I thought there might be a simple solution, but it doesn't look like it.
  23. I spent some time on that MSDN link, and it looks like an entire class on places where downloaded internet code is allowed to run and ways of storing "user, domain, and assemblies." I did a quick browse of it, but I didn't see what I was supposed to get from that. ...unless I missed something by skimming over it too fast. ...which happens sometimes. A Dial-Up Networking class is basically what I am looking to impliment or copy for use in our company's simple (very simple) FTP utility. What technique does Dial-Up Networking use to store/retrieve passwords? Where is that information stored?
×
×
  • Create New...