|
Ithaqua posted:Well, what happened was the async CTP installed a bunch of new stuff that targeted .NET 4.0. When you installed VS2012, it installed a new version of the framework, where all of that cool stuff is targeting .NET 4.5. On the minus side, installing .NET 4.5 on any machine will break my installed application. On the slightly plus side, uninstalling .NET 4.5 and reinstalling 4.0 fixes things.
|
| # ? Aug 16, 2012 17:20 |
|
|
| # ? May 20, 2013 19:14 |
|
I was seeing if I could use a <app>.exe.config to make my app use a specific version of .NET. In HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP I see the entries I expect - v2.0.50727, v3.0, v3.5, v4 and v4.0 ( how is this different than v4? ). The odd thing is that I don't see a 4.5 entry - the Version of the v4 has been updated to 4.5 instead of adding a new 4.5 entry. It was also installed in the v4.0.30319 directory and not a 4.5 directory. As far as I can tell 4.5 overwrites 4.0. Anyone have an idea as to why this would be the case? This seems like it could cause other issues due to changes in the Framework unrelated to the mess I'm in.
|
| # ? Aug 16, 2012 17:40 |
|
fankey posted:As far as I can tell 4.5 overwrites 4.0. Yup. It's something weird Microsoft did for some unfathomable reason. It's still 4.0.
|
| # ? Aug 16, 2012 17:44 |
|
fankey posted:So I've made 2 bad choices that I'm trying to figure out how to extract myself from. First, I used the Async CTP w/ VS2010. Then I decided to install VS2012 to see what porting to the new async stuff will look like. Not only did that break my ability to compile my code in VS2010 but it also broke my ability to run already compiled versions that use the Async CTP. I hadn't expected it to be that rough. (I was one of the team who did the async ctp). I had expected that: (0) Your code that you built with the asyncCTP (targeting mscore40 and AsyncCTPLibrary.dll) should still run even on a machine that replaces mscore40 with mscore45. That's because your compiled binary will be explicitly referencing types like AsyncCTPLibrary.dll::IAsyncStateMachine, rather than mscorlib::IAsyncStateMachine. (1) You should continue to be able to use VS2010+AsyncCTP since VS2012 can exist happily SxS with VS2010 and shouldn't touch it. (2) You would be able to load your projects into VS2012 but still targetting .NET4. You'd have to add the AsyncTargettingPack to make this work. (The AsyncTargettingPack is a replacement for the "AsyncCTPLibrary.dlll" that shipped with the CTP). This would require some changes to the async APIs that you invoke, but not too many. (3) You should be able to uptarget your projects to target .NET45. This would again require some changes to the APIs you invoke, but not many. I'd be happy to spend more time figuring out your situation to see what could be done, either on this thread or by email to me at lwischik@microsoft.com I'm sorry it's so difficult! Installer stuff was a nightmare. We the async-ctp team were a small group, and working with the installer (and VS2010's update cycle) took months of our time that we didn't want to spend, and ultimately there was no good way to ship an "OutOfBand" product like AsyncCTP have have it keep working reliably despite mainline updates to VS2010. And there were SxS scenarios we just didn't imagine.
|
| # ? Aug 16, 2012 18:24 |
|
I want to share some code with y'all, so I can be told how terrible I am at C# and hopefully improve a bit. Here's a (thread-safe?) ActionQueue. You can queue up actions from multiple threads and run them. I use it to write messages to a log file, broadcast messages to a list of clients, etc. https://bitbucket.org/epalm/csharp/.../ActionQueue.cs Usage: code:code:In EnqueueAndRun and Run, Does newEvent.Set(); need to be in the lock?
|
| # ? Aug 16, 2012 18:29 |
|
epalm posted:I want to share some code with y'all, so I can be told how terrible I am at C# and hopefully improve a bit. Wouldn't this do basically the same thing? code:Even if my code is missing the point and sucks, use a ConcurrentQueue.
|
| # ? Aug 16, 2012 18:51 |
|
ljw1004 posted:I hadn't expected it to be that rough. (I was one of the team who did the async ctp). I had expected that:
|
| # ? Aug 16, 2012 19:51 |
|
ljw1004 posted:First step: install Jared Parson's PInvoke Assistant! Sweet!
|
| # ? Aug 16, 2012 22:51 |
|
I've been looking at some posts on the repository pattern when used with Entity Framework and encountered something I haven't been able to figure out. Some examples, e.g. http://www.tugberkugurlu.com/archiv...esting-triangle, include an Update or Edit function and some do not. Why is that? I gather that the ones with an Update function let you work better "detached", but I guess I don't fully understand what that means or when you would work attached or detached. Is it that working attached means you always query the repository for entities and therefore the entities are always tracked and you would just SaveChanges() to make updates anyway? And Update just means starting to track a detached but already existing entity?
|
| # ? Aug 16, 2012 22:58 |
|
fankey posted:I was seeing if I could use a <app>.exe.config to make my app use a specific version of .NET. In HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP I see the entries I expect - v2.0.50727, v3.0, v3.5, v4 and v4.0 ( how is this different than v4? ). The odd thing is that I don't see a 4.5 entry - the Version of the v4 has been updated to 4.5 instead of adding a new 4.5 entry. It was also installed in the v4.0.30319 directory and not a 4.5 directory. As far as I can tell 4.5 overwrites 4.0. Anyone have an idea as to why this would be the case? This seems like it could cause other issues due to changes in the Framework unrelated to the mess I'm in. For some dumb rear end reason, and ignoring every single criticism, Microsoft decided to make .NET 4.5 an "in place" installation. Meaning, 4.5 overwrites 4.0 and then doesn't leave you with any way at all of knowing whether or not you're running in 4.0 or 4.5. While they claim they made sure to run all sorts of tests to ensure no one's programs get hosed up by this, I'm sure that lots of things will start cropping up soon enough. DO NOT install 4.5 unless you're ready to start testing that all your things compiled for 4.0 are still functional.
|
| # ? Aug 17, 2012 00:19 |
|
Ithaqua posted:use a ConcurrentQueue. The concurrent classes are so loving badass. I drat near poo poo myself when I found them. They are way, way, way faster (and sometimes cleaner looking) than locking around queues/dictionaries/whatever.
|
| # ? Aug 17, 2012 02:03 |
|
One word of caution with the Concurrent classes - ConcurrentDictionary and ConcurrentBag both incur an object allocation. If you're adding & removing at a high enough rate, they can actually hurt your Concurrency through heavy garbage collection. Edit: regarding the in-place 4.5 upgrade, I'd bet money they did it to shave one or two hundred megabytes off the Windows 8 install footprint, to help cram it in to 16/32GB flash devices.
|
| # ? Aug 17, 2012 03:26 |
|
I've hit a snag in a project I'm working on. I am using the following method to get a directory name from a user and then load all the filenames of picture files (bmp, etc) into an array. I use this to cast the filenames into Images, and it's working fine so far: code:What I'm stuck on now is figuring out a method to do the same opperation on a user-specified web address i.e. collecting the Images inside it into a circular linked list. Is there an object like OpenFileDialog for webpages, or should I do this another way? Thanks
|
| # ? Aug 17, 2012 13:43 |
|
Hot Yellow KoolAid posted:The aim is to put the Images into a circualr linked list that will play on a slideshow. I haven't run into any problems so far with this method. Here's what you're going to want to do: 1) Use a WebClient to download the page. 2) Parse the HTML with something like the HTML Agility Pack 3) Get all the images from the page. 4) Download the images to a temporary location (this is a perfect opportunity to use .NET 4.5's async/await!) 5) Use a normal dialog to select the images to display. Also, in the code sample you provided, you should be declaring myStream in the scope you're going to use it! I hate it when I see a null object created at the top of the method and it's not actually instantiated until halfway through the method. I decided to do it for some practice async/awaiting. Here it is! C# code:Ithaqua fucked around with this message at Aug 17, 2012 around 14:52 |
| # ? Aug 17, 2012 14:00 |
|
Zhentar posted:Edit: regarding the in-place 4.5 upgrade, I'd bet money they did it to shave one or two hundred megabytes off the Windows 8 install footprint, to help cram it in to 16/32GB flash devices. That doesn't really make sense as a justification. I actually have not heard a clear justification for why it was an in place upgrade, if anyone can find a link to a team member blog (or, any team member would like to respond here) I'd love to hear it.
|
| # ? Aug 17, 2012 14:14 |
|
I have a really crappy COM object I'm trying to code against. I've added the COM as a reference, but when I try to use it I keep getting this error: Unable to cast COM object of type '<blah>' to interface type '<blah>'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{E1496B92-4BD6-11D2-95B9-0000C0BE33E7}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). The only way I've gotten it to work is using Type.GetTypeFromProgID() which returns a System.__ComObject type, and then I can use Activator.CreatInstance() and InvokeMember. It's a huge pain in the butt, but I can't figure out how to actually make the objects usable in C# the way they should be.
|
| # ? Aug 17, 2012 14:14 |
|
Frozen-Solid posted:I have a really crappy COM object I'm trying to code against. I've added the COM as a reference, but when I try to use it I keep getting this error: You've most likely got the wrong IID number there! InvokeMember never uses the IID. It instead goes via IDispatch or IDispatchEx. The fact that InvokeMember works, reinforces my suspicion that you've got the wrong IID number. It's impossible to answer your question without seeing more code. I'd STRONGLY recommend coding up a C++ example that works (using QueryInterface). Then show us the C++ code, the C++ header file that describes the COM object, your C# class+interface definitions for the COM object, and the C# code you're using to work with it.
|
| # ? Aug 17, 2012 15:22 |
|
Or just cast it to dynamic and call it a day.
|
| # ? Aug 17, 2012 15:25 |
|
ljw1004 posted:You've most likely got the wrong IID number there! I'm never calling the IID anywhere. I'm just using straight objects from the referenced COM. LabelVision.Application app = new LabelVision.Application(); //Works! LabelVision.Label label = app.OpenLabel(Application.StartupPath + Path.DirectorySeparatorChar + "Label.lbx"); //Fails! Full error: Unable to cast COM object of type 'LabelVision.ApplicationClass' to interface type 'LabelVision.IApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{E1496B92-4BD6-11D2-95B9-0000C0BE33E7}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). Code that works: Type lvAppType = Type.GetTypeFromProgID("LabelVision.Application"); object lvApp = Activator.CreateInstance(lvAppType); object lvLabel = lvAppType.InvokeMember("OpenLabel", BindingFlags.InvokeMethod, null, lvApp, new object[] {Application.StartupPath + Path.DirectorySeparatorChar + "Label.lbx"}); GetTypeFromProgID returns a System.__ComObject. I can't figure out how to cast that into anything useful besides just using generic objects. The code that works is okay, because I can just wrap it in a C# class object, but i don't think I should really have to do that. Of course the company that made the COM is useless, and just wants money for "Custom Application Design" support. All their documentation is for VB and looks like it should "Just Work" using VB's GetObject and CreateObject functions, but I'd rather not resort to VB if I don't have to. Frozen-Solid fucked around with this message at Aug 17, 2012 around 17:02 |
| # ? Aug 17, 2012 16:30 |
|
Are there any unique identifiable file properties? For instance, c:\mydocument.doc vs. c:\documents\mydocument.doc. Would there be an attribute or something that I could use to distinguish between the 2? I know I can look at file date, file size etc. but rightfully assuming those attributes can change and/or be the same I need something else. We have assembly version, file version and assembly guid for assemblies so I'm looking for something similiar on files.
|
| # ? Aug 17, 2012 19:38 |
|
Essential posted:Are there any unique identifiable file properties? For instance, c:\mydocument.doc vs. c:\documents\mydocument.doc. Would there be an attribute or something that I could use to distinguish between the 2? If you're looking for bit-for-bit comparison between the two documents, System.Security.Cryptography has an SHA1 class.
|
| # ? Aug 17, 2012 19:59 |
|
Ithaqua posted:Well, what happened was the async CTP installed a bunch of new stuff that targeted .NET 4.0. When you installed VS2012, it installed a new version of the framework, where all of that cool stuff is targeting .NET 4.5. Meh, I did and I'm not regretting it. It even has a license that you're allowed to use it in production code, so. The only problem was when I tried the VS2012 preview, because that was really incompatible with the async CTP. I guess I'll have the same problem when I install the real 2012 in a few months, but at that point I'll just throw 2010 in the bin and upgrade everything.
|
| # ? Aug 17, 2012 20:06 |
|
uXs posted:Meh, I did and I'm not regretting it. It even has a license that you're allowed to use it in production code, so. I have determined that I can use VS2012 with the Async Targeting Pack to compile my app targeting 4.0 and it will run with either 4.0 or 4.5 installed.
|
| # ? Aug 17, 2012 20:12 |
|
So this is baffling me. I'm playing around with this little portable bar code scanner and the SDK it came with only supports C++ and VB ![]() I found some open source third-party library in C# that interfaces with the device and I was able to rip apart the code and get some real bare-bone functionality that we need. My problem is that their code, which I don't understand at all, gets the barcodes with the date and time it was scanned from the device and returns that. If I just use their method to get the information, it's good. But we don't want the time and date attached to it. so I have code:
|
| # ? Aug 17, 2012 20:19 |
|
Sab669 posted:So this is baffling me. I'm playing around with this little portable bar code scanner and the SDK it came with only supports C++ and VB What format is the data in? That algorithm looks atrocious and there's probably a better way to strip the dates. I'm not saying your algorithm is the problem, but I can almost guarantee you there's a more elegant solution to the problem. Super anal style nitpicking: C# method names should be UpperCamelCase.
|
| # ? Aug 17, 2012 20:28 |
|
I know it's pretty ugly ![]() I had something recursive before but it kept causing stack overflows when there were a large number of barcodes stored on the device. A sample of the output without any modification from me: quote:609465149776, 8/17/2012 3:22:58 PM I just scanned a bunch of things on my desk, so now that you mention it maybe the end product would have more... expected style of information. I'll have to go check with my boss next time he's in the office.
|
| # ? Aug 17, 2012 20:32 |
|
Ithaqua posted:Super anal style nitpicking: Ooh ooh can we have the "my style guide is the only style guide" discussion again?
|
| # ? Aug 17, 2012 20:32 |
|
Che Delilas posted:Ooh ooh can we have the "my style guide is the only style guide" discussion again? Nope. My style guide is Microsoft's, so that's a pretty good starting point.
|
| # ? Aug 17, 2012 20:36 |
|
Sab669 posted:I know it's pretty ugly Try this: C# code:
|
| # ? Aug 17, 2012 20:42 |
|
Ithaqua posted:Nope. My style guide is Microsoft's, so that's a pretty good starting point. Right, which is the style guide Microsoft uses for MSDN examples (and I assume internally?), which has nothing to do with anybody else's code base. Its guidelines do not supercede being consistent with your own code base. His method names are internally consistent (all 2 of them that we see, heh), so it's perfectly valid. For the record, I happen to use Microsoft's guidelines in my own work. Mostly because they're all written out and easily referenced, and there's nothing really wrong with them.
|
| # ? Aug 17, 2012 20:42 |
|
Essential posted:Are there any unique identifiable file properties? For instance, c:\mydocument.doc vs. c:\documents\mydocument.doc. Would there be an attribute or something that I could use to distinguish between the 2? http://blogs.msdn.com/b/vbteam/arch...an-wischik.aspx but read the comments for caveats
|
| # ? Aug 17, 2012 21:22 |
|
Che Delilas posted:Right, which is the style guide Microsoft uses for MSDN examples (and I assume internally?), which has nothing to do with anybody else's code base. Its guidelines do not supercede being consistent with your own code base. His method names are internally consistent (all 2 of them that we see, heh), so it's perfectly valid. Exactly -- internal consistency is the only thing that matters at the end of the day. Personally I prefer the lowerCamelCase for all private members -- easier to tell what things are at a glance without ruining the semantics. Does anyone know why the UpperCamelCase fatwa came down?
|
| # ? Aug 17, 2012 22:15 |
|
wwb posted:Exactly -- internal consistency is the only thing that matters at the end of the day. My guess is that because that's how the .Net Framework names its own stuff. Which is in fact a good argument for doing it Microsoft's way, since non-trivial programs generally make extensive use of the Framework libraries. Code autocomplete tools like Intellisense are also so good now that a lot of the older naming conventions (some of which shall remain nameless) are unnecessary. And good riddance. The only names that are in camel case that I know of in Microsoft's style guide are fields, function params and locally scoped variables. That's enough, in my opinion, since if I'm calling a class's function from within another function of the same class, I don't really care if the function I'm calling is public or private.
|
| # ? Aug 17, 2012 23:49 |
|
What should I know if I'm going to be applying for junior C#/.NET developer jobs? I want to work toward getting up to that level, but I don't really know what that level is. I've done a couple of small projects in C#, but nothing that really took advantage of more than basic language features, and I didn't really use any of the framework besides some simple WPF and a couple collections classes. I'm guessing that being very familiar with everything in System.Collections is a must, but what else? I ask because I'm currently an intern doing test automation, but one of the people leading the team have said they're thinking of moving me to development if it looks like we don't really need much to maintain our UI test suite, while another said that they only intended for the intern to work in testing for a couple months to get familiar with the product before moving to development. I want to be productive ASAP if that happens, but all I really know is that they use C# and WCF for the back-end of their product.
|
| # ? Aug 18, 2012 01:19 |
|
Safe and Secure! posted:What should I know if I'm going to be applying for junior C#/.NET developer jobs? I want to work toward getting up to that level, but I don't really know what that level is. I've done a couple of small projects in C#, but nothing that really took advantage of more than basic language features, and I didn't really use any of the framework besides some simple WPF and a couple collections classes. Make sure you're familiar with this stuff: - Fundamental understanding of OO principles (abstract classes, interfaces, how and why you'd use them) - SOLID design principles - Unit testing / IOC - LINQ and why it's awesome - Generics and why they're awesome - In general, know how to write clean code (small classes, small methods, sanely named classes/methods/variables) A few jobs ago I was responsible for technical evaluations for interviewees, and I've done a bunch of mock interviews with folks from COC. If you want to set one up, shoot me a PM or give me an email address where I can contact you.
|
| # ? Aug 18, 2012 01:42 |
|
wither posted:If you're looking for bit-for-bit comparison between the two documents, System.Security.Cryptography has an SHA1 class. ljw1004 posted:http://blogs.msdn.com/b/vbteam/arch...an-wischik.aspx Thank you for the suggestions guys. I'll look into them both and see if that accomplishes what I need. I should have added to the original post that I need to track 1 file as the 'working' file. I don't know if the above solutions will work because of that but both are a step in the right direction at least.
|
| # ? Aug 18, 2012 01:51 |
|
Would the File.Exists class work on something that is online? I am sometimes getting server errors when the XML file im using is getting created. So I want to put a safeguard checking that it's there before rendering. The address is http://*.*.*.*/status.xml and putting that into the arguments results in it always being false. Vintersorg fucked around with this message at Aug 20, 2012 around 18:47 |
| # ? Aug 20, 2012 18:44 |
|
Vintersorg posted:Would the File.Exists class work on something that is online? I am sometimes getting server errors when the XML file im using is getting created. So I want to put a safeguard checking that it's there before rendering. No, all of the File methods are for the local filesystem. You can do something like this to see if it exists on a web server: C# code:Ithaqua fucked around with this message at Aug 20, 2012 around 18:57 |
| # ? Aug 20, 2012 18:54 |
|
I'll add that top stuff re: 404's, that will be more precise. After I posted the above I just threw everything into a try/catch and get the user to try again momentarily as a refresh will usually work right away.
|
| # ? Aug 20, 2012 19:02 |
|
|
| # ? May 20, 2013 19:14 |
|
Ithaqua posted:No, all of the File methods are for the local filesystem. Shouldn't you be looking into the WebException's Status rather than digging into the error message. Loads cleaner . . .
|
| # ? Aug 20, 2012 19:14 |





















