|
How about running the C# file through the C++ preprocessor before build?
Somewhere in the SVN of xacc.ide I have a wrapper for 'cl -E' to process C# files (takes care of #regions). Maybe that will be of help.
I see no reason why you should not use the C# 3.0 compiler to target .NET 2, however
|
|
|
|
|
leppie wrote: through the C++ preprocessor
I already do that, at least for command-line builds, but only to prove that I can.
"C:\Program files\mingw\bin\cpp" -include "C:\Projects\PIEBALD\Defines.hs" -P -C -w %1.cs %1.csi
csc.exe @"C:\batfiles\Build.rsp" %1.csi
(Some details removed.)
And, yeah, it won't work if the file contains directives it doesn't understand.
However, this is based on how I dealt with directives when pre-processing embedded Oracle and RDB in C.
leppie wrote: I see no reason
I'm thinking of people who are stuck with VS2005.
Oh, and I did finally read up on xacc.ide and downloaded it, but that's as far as I've gotten so far.
|
|
|
|
|
Oh, and it's not entirely for how I build, but if/when I write a method to post here I may choose to write it as an Extension Method for the users who use them, but not have it break for the users who are using .net 2.
If I can, I should; if I can't, then I'll leave it out.
|
|
|
|
|
Ahh...that makes sense I suppose. I don't think I would worry too much about it, personally, but that's just me.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Running Vista (without SP1)
Working in VS2005
I am streaming a large file (a 900mb FLV movie) over localhost, but just past the halfway, the program throws this exception:
The specified network name is no longer available at System.Net.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 size)
We've tried the program on 5 machines (both XP and Vista), and it works on everybody's but mine.
Does anyone know why and/or have a solution?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I am not sure but, when you open any webpages on local machine, at first time windows will ask you to "Enable Intranet Settings" for better performance on information bar. check that settings. may be its blocking larg file streaming.
|
|
|
|
|
I'm not using IE as my default browser.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: or have a solution?
Steal one of the machines it works on.
led mike
|
|
|
|
|
John Simmons / outlaw programmer wrote: Does anyone know why and/or have a solution?
Anti virus, firewall? Maybe the firewall kicks in at some threshold?
Dodgy network drivers?
|
|
|
|
|
Well, I noticed that it happened in at the same spot in the file *every time*. So, I tried two other files and it worked like a champ. I suggested that we re-encode the defective file and see if that helps.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Have a look in the eventlog, make it's a bad area on the disk?
|
|
|
|
|
I chose to slow down the speed at which we were streaming the file. That seems to have worked.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hello,
I am writing a program that sends mail and let the user mange his mail locally in his computer.The second requirement is a little hard how can I use the IMAP protocol to connect to the remote mail server and download the mail like outlook using C#.
Thanks.
Dad
|
|
|
|
|
There are some articles on POP3 and IMAP available, for instance check out this one[^].
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
How to run a DTSx package in the .NET framework 2.0 using com object
Thanks in Advance
Regards & Thanks,
Paresh
Paresh Gujararathi
modified on Thursday, July 10, 2008 8:37 AM
|
|
|
|
|
I am just starting my adventure with test driven development (thanks to ASP.NET MVC!) and have a concern, I need to clarify something.
I have an interface like this...
public interface IUserRepository
{
IUser FetchByID(int userID);
}
and a class which implements that interface:
public class UserRepository : IUserRepository
{
public IUser FetchByID(int userID)
{
User user = null;
return user;
}
}
I want to test the FetchByID() method. I can mock IUserRepository and return a dummy User object, which is fine and works well. But this means the concrete class (UserRepository ) is never tested, so even if I didn't implement that class whatsoever, or I had throw new NotImplementedException() in that method the unit test would still pass since it's using a mock object. I thought you don't want to hit the database (or other external resources) while running your tests and that's the main reason to use mock objects, but that way you never can tell if you implemented that class correctly (or at all!). My colleague told me that when I'm testing that method I should use the concrete class and actually hit the database, and that I should mock IUserRepository only when it's needed in other tests (which are not testing FetchByID() but need data from it). Is that the correct approach?
If so, then my tests will get slower and rely on whether the test DB was properly setup, etc. Perhaps such tests should be placed in a separate project (integration tests)?
|
|
|
|
|
Pawel Krakowiak wrote: I thought you don't want to hit the database (or other external resources) while running your tests and that's the main reason to use mock objects
The concept is; "Each test should be isolated". AFAIK, the way you are testing "FetchById " is not correct. When you are testing FetchById , mocking IUserRepository won't make any sense. You will always get the expected "IUser" instance and as you said, it is not testing the real method. You have to mock only items that are nondeterministic in behaviour.
Pawel Krakowiak wrote: My colleague told me that when I'm testing that method I should use the concrete class and actually hit the database, and that I should mock IUserRepository only when it's needed in other tests (which are not testing FetchByID() but need data from it). Is that the correct approach?
Not exactly. As I said earlier, tests should be isolated. So if you are hitting database for each time, or the database you are using is a shared one, the test which executed successfully one time won't get executed next time as the data in database might have changed. So if you are not testing databases, mock/stub the data access which will help to get the test running quickly.
Consider the modified code
public class UserRepository : IUserRepository
{
IUserDataContainer container;
public UserRepository(IUserDataContainer container)
{
this.container = container;
}
public IUser FetchByID(int userID)
{
User user = null;
UserDTO dto = dataContainer.FetchUserFrom(userId);
user = UserConverter.ConvertFrom(dto);
return user;
}
} I have added a "IDataContainer" to your example which is for fetching the data. Added a parameterized constructor which can be used inject the "IDataContainer" (Dependency Injection).
According to "FetchById" method, getting data is from an external source. So that has to be mocked. So if you follow the example what I given, you can easily mock the data access and test "FetchByid" alone.
If in any other places "FetchById" is using, then you should mock "IUserRepository" and set expectations on "FetchById" method.
Are you using inbuilt testing tools in VS or tools like NUnit ? From my experience, I think MVP is better than MVC for testing.
Hope this helps
|
|
|
|
|
When I re-read your post, I had a feeling that you are not using TDD. You are writing tests but it's not test driven, is it ? If you write the test case in the begining, you might have avoided this confusion.
Initially you write the test something like
[Test]
public void CanFetchUserById()
{
UserRepository repository = new UserRepository();
IUser user = repository.FetchUserById(1);
Assert.That(user != NULL);
Assert.AreEqual(user.Id,1);
Assert.AreEqual(user.Name,"Jim");
} Now to make this test compile, you add a skeleton "FetchById" method to "UserRepository" class.
public IUser FetchByID(int userID)
{
throw new NotImplementedException();
} Now your test will compile, but it will fail. Now come back to your "FetchById" method and add it's implementation. You find that it needs an external source like database to complete processing. So you mock the database access to make your test isolated.
Hope this makes it more clear.
|
|
|
|
|
Hey, I'll answer both of your posts in one place, OK?
N a v a n e e t h wrote: Are you using inbuilt testing tools in VS or tools like NUnit ?
I'm using MSTest which is built-in in VS2008 and moq[^].
I'm not using the database directly, though, I am using SubSonic[^] to generate my DAL classes, it's an ORM tool (perhaps you know it) and inside the FetchByID implementation I would have something like this (to simplify I'm not checking for nulls, etc.):
public IUser FetchByID(int userID)
{
IUser user =
new UserController().FetchByID(userID).ExecuteTypedList<User>()[0];
return user;
}
UserController is a generated class, internally it calls a database, retrieves records from it and maps to result to a typed list of User instances (because I tell it to by invoking the ExecuteTypedList method).
N a v a n e e t h wrote: You are writing tests but it's not test driven, is it ?
It IS test driven. Actually my coding/thought process was exactly the same as yours, I wrote my test first (CanFetchUserById here) and then implemented the FetchByID user on my UserRepository class (see above for the actual implementation using SubSonic) - and that's where I am blocked. I saw that I need to call SubSonic there, but I don't want to access the database in a unit test and didn't know how to do this. I mocked the IUserRepository interface but just as you say this wasn't testing the real method - the FetchByID() method on the mocked object would always return correct data, because after all I'm telling it to (through expectations), right?
I don't know how much of this discussion is clear to you, because it would help if you knew SubSonic a little (I don't know if you do) or another similar ORM with its query syntax. What I think of doing is not using SubSonic in my repository classes directly, but to move it down to the DAL and use it only there, so I would have something like this:
o DAL, which has SubSonic generated classes. Here I would introduce several "providers", e.g. UserProvider which implements IUserProvider which has FetchByID() method.
o Services/BLL which has my own repository classes, which have constructors accepting interfaces, e.g. a UserRepository class which implements IUserRepository and has a constructor which accepts a IUserProvider instance, so I can use dependency injection.
Let's see a "working" example of this...
namespace Example.Data
{
public interface IUserProvider
{
UserDTO FetchByID(int userID);
}
public class UserProvider : IUserProvider
{
public UserDTO FetchByID(int userID)
{
UserDTO user =
new UserController().FetchByID(userID).ExecuteTypedList<UserDTO>()[0];
return user;
}
}
}
namespace Example.Services
{
public interface IUserRepository
{
IUser FetchByID(int userID);
}
public class UserRepository
{
private _provider = null;
public UserRepository(IUserProvider provider)
{
this._provider = provider;
}
public IUser FetchByID(int userID)
{
UserDTO dto = _provider.FetchByID(userID);
User user = UserConverter.ConvertFrom(dto);
return user;
}
}
}
namespace Example.Tests
{
[TestClass]
public UserRepositoryTest
{
[TestMethod]
public void FetchByID_ReturnsUser()
{
var provider = new Mock<IUserProvider>();
provider.Expect(p => p.FetchByID(1)).Returns(new User("John", "Doe"));
IUserRepository rep = new UserRepository(provider);
IUser user = rep.FetchByID(1);
Assert.IsNotNull(user);
Assert.IsEqual("John", user.FirstName);
Assert.IsEqual("Doe", user.LastName);
provider.VerifyAll();
}
}
}
Is that more or less what I need? But now another question comes to mind - do I test the UserProvider? It uses SubSonic... It might as well use ADO.NET, I think it's not so important if it's SubSonic or not. Essentially after adding all this nice code I'm still at the same point - I know how to test UserRepository , but I just added UserProvider in my DAL and don't know what to do with THAT. The question is - where does all this testing end? Where's the boundary?
|
|
|
|
|
Hello all,
I posted a question recently on using a SDK from an ASP.NET application and got some answers that made me rethink how i should approach an application i need to build.
Basically I have an ASP.NET application that needs to interact with a piece of hardware when either a user wants to interact (they tell the hardware to do something e.g. turn on turn off) or periodically (we poll for information from the hardware). Unfortunately the SDK only allows one call at a time so I need to provide my own locking around the SDK to ensure firstly that two asp clients attempt to interact with the hardware at the same time and secondly that a user doesn’t try to interact whilst a periodic action is taking place.
After some research and some questions on various forums I have decided to create a windows service which will create static instance of the SDK and the call these methods from the ASP.NET application through IPC remoting channels. From what I have read I will need to create two DLL’s one to interact with the SDK and contain the business logic and a DLL which will be used for the remoting objects.
Am just wondering if this seems the most logical way to tackle this problem or if anyone can think of a different/more efficient way or can see any holes in my solution. Am completely lost by this now as i can't find any examples of doing this it all seems to be about using web services but because i want to keep the state of the SDK object i didnt think i could use these??!!
Thanks,
Adam
|
|
|
|
|
Where is the hardware, on the server ? If it's not, I'm not sure how you'd make this work ?
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
The hardware is communicated to via TCP/IP.
If it helps the hardware is a door controller which manages locking and unlocking doors.
The information that i poll from it is about access transactions.
Why do you think this will not work?!
|
|
|
|
|
b/c I expected you were connecting to something via USB or something, a lot of people get confused about what code runs on the server and what runs on the client, while they develop. If it's using TCP/IP, I guess that would work fine.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
If you need to periodically poll the device for information (and then store it in a database) then a Windows Service is likely the best way to do that.
For allowing users to send commands to the device you could have a table of such commands/requests.
The client would insert a request (perhaps via a WebService), the Windows Service would then perform (or deny) them. This would form an audit trail of such events.
|
|
|
|
|
I'm trying to check if a CD had been burnt using ISO 9660 level 1. I've looked at using win32_CDROMDrive but can't identify what whould tell me the format type. I thought maybe it would be in win32_diskPartition but I don't seem to be able to see any CD information using that (just my 2 partitions on the fixed disk).
Is there a reasonably simple way of identifying the filesystem on the disk?
Thanks
Arron
|
|
|
|
|