Click here to Skip to main content
15,172,725 members

Comments by Oleksandr Kulchytskyi (Top 200 by date)

Oleksandr Kulchytskyi 27-Feb-15 7:06am View
Ok, thank you very much for the help.
I appreciate it!
Will be needed to extend my knowledge in JIT optimization.
Oleksandr Kulchytskyi 27-Feb-15 5:32am View
But to be honest [MethodImplAttribute(MethodImplOptions.NoInlining)]
does't help.
Oleksandr Kulchytskyi 27-Feb-15 5:32am View
Yep, you are completely right!
The main showstopper is compile optimization during release mode.
In such case , since fr.Read(); is returned void , CLR treated FileReader fr as a garbage and finalize it.
Oleksandr Kulchytskyi 27-Feb-15 4:15am View
Hi, see the error exception image
Issue happens during reading lines in PerformRead method and the main reason why, this is because the finalization of FileReader took place.
As a result StreamReader object has been closed.
Oleksandr Kulchytskyi 11-Feb-14 3:44am View
There are a lot of samples here:

the articles above related to the WCF duplex communication, what is concersn signalR read about it on the Microsoft site.
With regards, Oleksandr.
Oleksandr Kulchytskyi 24-Apr-13 5:10am View
Reason for my vote of 5 \n Nice one!
Oleksandr Kulchytskyi 26-Mar-13 4:12am View
Wow, i'm a bit wondering with your implementation...
Do you know, that after first read operation was perormed you stream will seek to the value of read bytes, as a result stream position will be = number of read bytes??
Oleksandr Kulchytskyi 26-Mar-13 4:08am View
Did you try to use WebClient and set action method to POST ??
Oleksandr Kulchytskyi 18-Mar-13 10:06am View
Well if be honest, for now i have no issues. I just want to get the whole idea of transferring voice stream in HTML5 client or even to know if there is such ability to do it??
In case of Yes, i also would like to know if it would work in mobile view, lets say in IOS 4+?
Oleksandr Kulchytskyi 17-Mar-13 12:24pm View
Well if be honest, for now i have no issues. I just want to get the whole idea of transferring voice stream in HTML5 client or even to know if there is such ability to do it??
In case of Yes, i also would like to know if it would work in mobile view, lets say in IOS 4+?
Oleksandr Kulchytskyi 21-Jan-13 13:41pm View
Ouhh, yep , from that point of view, you are completely right!
Oleksandr Kulchytskyi 21-Jan-13 5:15am View
Why abuse ? If i will be using System.Threading.Timer ,which performs counting on separate thread, so no overheads on UI thread. Furthermore, if we try to inject Rx to aforementioned approach and change existing behavior to push, with this approach we can extremely reduce some overheads to UI part.

Maybe you can advise some more advanced approach, i would like to hear it, because you have a spot and always have been giving nice advices =)
Oleksandr Kulchytskyi 15-Jan-13 5:29am View
Reason for my vote of 1 \n Omg!
What about sql injection in your scripts (SQL injection problem)? Very poor.
Oleksandr Kulchytskyi 10-Jan-13 9:00am View
What will happen if I used some session variables for all users????
What do you mean?
if you add some data to Session storage this data will be only avaliable for 1 user whic issued this session!!
if you want to access to some variable storage for more than only 1 user use Application level storage instead of Session
Oleksandr Kulchytskyi 7-Jan-13 14:52pm View
ok =) i'm glad
Oleksandr Kulchytskyi 3-Jan-13 4:30am View
Nope, it's require self implementation and self design.
About SignalR , you can read here
Oleksandr Kulchytskyi 29-Dec-12 18:54pm View
Why did you replicate your question?? if you can just improve the old!! You produce a spam!
Oleksandr Kulchytskyi 29-Dec-12 18:46pm View
Man , what is wrong with you??? i have been answered on your previous question..
Why did you ask that again????
Oleksandr Kulchytskyi 29-Dec-12 9:19am View
Reason for my vote of 2 \n Where is a lazy initialization?
Oleksandr Kulchytskyi 29-Dec-12 9:01am View
As far as i remember you have asked such question!
Oleksandr Kulchytskyi 29-Dec-12 8:11am View
Oppss, sorry about that.
Oleksandr Kulchytskyi 29-Dec-12 6:06am View
Oleksandr Kulchytskyi 29-Dec-12 5:57am View
Well i completelly confused. as far as i understood UF17DataDownloader itself is your web service ?
As concerns real web-services in dot Net, where does you host it ? And which type of service WCF ?
If yes and it host in windows enviromnemnt , though:

host = new ServiceHost(serviceType);
host.Open(); //-- start WCF service;


host.Close(); // -operation that stops WCF service.

In case os IIS hosting of web-service ... this won't work.,..
Oleksandr Kulchytskyi 29-Dec-12 5:26am View
Ok, wait few minutes... and i will provide you with basic idea.
Oleksandr Kulchytskyi 29-Dec-12 5:06am View
Whithout any internals of UF17DataDownloader i can't advise you smth.
Oleksandr Kulchytskyi 29-Dec-12 4:50am View
Ok, where did you get this UF17DataDownloader?
This module was written by U?
Oleksandr Kulchytskyi 29-Dec-12 4:39am View
So please provide us with you code where you have been working with Media Element !
Without code anyone cant help you!
Oleksandr Kulchytskyi 29-Dec-12 4:35am View
What does it mean API?? What exact API?
ASP.NET WEb API ?? or what?
Oleksandr Kulchytskyi 28-Dec-12 10:52am View
So =)
As far as i understand, you need complex turtorial about relationships between tables in EF and it's configuration???
Oleksandr Kulchytskyi 28-Dec-12 9:50am View
You are welcome.
Oleksandr Kulchytskyi 28-Dec-12 9:47am View
1) i write application using NHibernate with configuration MS Sql server.-
In which form this configuration is persisted? in case of FLUENT API, my answer is NO, otherwise (in case of xml config), - YES.

NHibernate is some aspect is a replication (porting code from JAVA platform to C#) + some complementary changes have been added (such as LINQ - which is not characteristic of JAVA)
Oleksandr Kulchytskyi 28-Dec-12 9:04am View
Oleksandr Kulchytskyi 28-Dec-12 9:04am View
You are welcome! accept solution if you dont mind :)
Oleksandr Kulchytskyi 28-Dec-12 7:56am View
Sorry for so late response....
But if be honest, in my turn, i do not understand U..
What did you expect? If you are expected that i will write a whole explanation turtorial about implementing the same func like Java Hibernate but in consideration of NHibernate...
Do you know how much time it can takes?
I have shared to you from my Skydrive a link to a book, please read it!!!!4507&authkey=!AKPW5f3sM0xm0ig
Oleksandr Kulchytskyi 28-Dec-12 7:51am View
Which errors???
Oleksandr Kulchytskyi 28-Dec-12 6:28am View
Ohhh , sorry for my inattentiveness. Now i have caught what you mean..
Yep of course this things are still relevant for NHibernate.
Oleksandr Kulchytskyi 28-Dec-12 6:24am View
Furthermore, in you injected in your solution such things as DI, and IoC,
you can achive functionality of replacing of usage differ DB servers on runtime , for example using config files.
Oleksandr Kulchytskyi 28-Dec-12 6:06am View
Elaborate you question! Wich framework did you use ???
WinForms , WPF ??
Oleksandr Kulchytskyi 28-Dec-12 5:55am View
How do you think , how can we help you from that little description??
Maybe it would be more efficient to add some exception message ??
Please accomplish your question
Oleksandr Kulchytskyi 28-Dec-12 5:33am View
So what do you meand in term of "multiple database server"?
Is it the same server architecture , but in differ location???
Or you mean various DB servers??
Oleksandr Kulchytskyi 28-Dec-12 5:24am View
So, accept the solution if it was helpful, please ;)
Oleksandr Kulchytskyi 28-Dec-12 5:23am View
Which exact data you want to store in DB???
Oleksandr Kulchytskyi 28-Dec-12 5:14am View
Yep, of course you can get rid of creating proxy class...
One of the possible reasons why you cannot receive data it to need specify some additional argument in header request via web client.

Also i would reccomend to add aditional check point:
void wClient_OpenReadCompleted(object sender, DownloadStringCompletedEventArgs e)
// log error state ....
XNamespace ns = "";
XDocument xdStudent = XDocument.Parse(e.Result);
var Result = (from emp in xdStudent.Descendants(ns +"Employee")
select new Employee
EmpNo = emp.Element("EmpNo").Value,
EmpName = emp.Element("EmpName").Value

dgData.ItemsSource = Result;

Oleksandr Kulchytskyi 28-Dec-12 4:44am View
Omg, could you please elaborate you qustion ??
Which technology, framework etc??
Oleksandr Kulchytskyi 28-Dec-12 4:01am View
Unfortunatelly, We cannot work from this little that you have described to us...
Provide community with sources
Oleksandr Kulchytskyi 28-Dec-12 3:41am View
Please , elaborate your question!!! Describe in more details about your specific issue
Oleksandr Kulchytskyi 28-Dec-12 3:40am View
So what a problem ??? Any issues with replacing instead of combobox to put listbox??
Oleksandr Kulchytskyi 28-Dec-12 3:32am View
Yep of course , they cause the parsing issue , because of you forget to add xml namespaces to your xdoc
Oleksandr Kulchytskyi 28-Dec-12 3:03am View
How how ?) Easily ,you need to be referenced to all necessary assemblies and begin to develop ;)
Oleksandr Kulchytskyi 28-Dec-12 2:53am View
So what's the problem ?
Who told you that with SignalR you will be able to develop only a group chat ?))
Oleksandr Kulchytskyi 28-Dec-12 1:45am View
Yep, completely agree with you, in that answer i had to pay more attention while have been mentioned about Equals method, but for some reason i have missed that,
And of course List<t>.Find, also is quite good enough.
Thank for correction!
Oleksandr Kulchytskyi 27-Dec-12 16:30pm View
As usual very informative and effective , my 5.
Oleksandr Kulchytskyi 27-Dec-12 15:45pm View
Did you try to do anything ?? Or you expecting to receive code ?
Oleksandr Kulchytskyi 27-Dec-12 15:07pm View
thanks !)
Oleksandr Kulchytskyi 27-Dec-12 14:51pm View
Thanks :)
Oleksandr Kulchytskyi 27-Dec-12 14:24pm View
I saw that somefuc returns a bytes array , that is all what i know.
But what exact it does? which encodings , and so on??
Oleksandr Kulchytskyi 27-Dec-12 14:22pm View
Hm , i think No.
Oleksandr Kulchytskyi 27-Dec-12 11:58am View
Yep , it similar to First(), expect one thing in case if there is no such element with specified criteria , method will return null.
And yep again, under the hood of LINQ located old-plain foreach , for =))
Oleksandr Kulchytskyi 27-Dec-12 11:53am View
What about
using System.Reactive.Linq ??
Oleksandr Kulchytskyi 27-Dec-12 11:36am View
Please provide community with your code!
Oleksandr Kulchytskyi 27-Dec-12 11:34am View
Yep fully agree with you, Session state is one of the most suitable solution for it. My five to U.
Oleksandr Kulchytskyi 27-Dec-12 11:33am View
You are welcome, contact me if any ;)
Oleksandr Kulchytskyi 27-Dec-12 11:32am View
=)I wish you good luck !) Have a nice coding procedures ;)
Oleksandr Kulchytskyi 27-Dec-12 11:13am View
=) Well, obviously, you didnt catch the whole idea of MVVM pattern, the main idea is delimnit your logic from view , though , there must be no code in your view....

So lets, go back to your question, it's possible, buts from code clean consideration more polite will be usage of declarative
Oleksandr Kulchytskyi 27-Dec-12 10:22am View
"But do you know, that there is no other way to bind via xaml for me? (so i can mark this question as answered...)" - what do you mean?
There are 2 ways to declare bindings: imperative and Declarative.
The way like you did is called imperative, the way like i suggest is declarative.
Oleksandr Kulchytskyi 27-Dec-12 9:43am View
Agree , patterns is not a bible, but they are something that devs you should consider :)
Oleksandr Kulchytskyi 27-Dec-12 9:32am View
Thanks for your mark,you are welcome =)
Oleksandr Kulchytskyi 27-Dec-12 9:30am View
Obviously yes, you must(might ) review you architecture approach...
good application design is one of the crucial aspect in software development.
Oleksandr Kulchytskyi 27-Dec-12 9:21am View
As concerns binding in the code, define a lot of ViewModels and bind it in XAML
Oleksandr Kulchytskyi 27-Dec-12 9:20am View
As concerns RaisePropertyChanged read this

Oleksandr Kulchytskyi 27-Dec-12 8:27am View
you deploy it localy ? In case of yes, so choose anothe option to deploy.
Oleksandr Kulchytskyi 27-Dec-12 8:23am View
So, create your own application in IIS,
run inetmgr, go to sites node , create your own web app,
and deploy via your's web-service to that app.
Oleksandr Kulchytskyi 27-Dec-12 7:55am View
So if you mind,please rate our answer ;)
Oleksandr Kulchytskyi 27-Dec-12 7:37am View
I knew it ;)
But anyway thanks, i think it will be useful for questioner!
Oleksandr Kulchytskyi 27-Dec-12 7:36am View
I knew it ;)
But anyway thanks, i think it will be useful for questioner!
Oleksandr Kulchytskyi 27-Dec-12 7:10am View
Any exception??
Oleksandr Kulchytskyi 27-Dec-12 7:07am View
As concerns INPC , i think you are completelly mistake!
What would be if you develop some input , and while try to input FirstName , now do you think does WPF will track property changes ???
My answer is now...
Oleksandr Kulchytskyi 27-Dec-12 7:05am View
So, make double check! What a problem?)
return "Name cannot be empty";
if (!Regex.IsMatch(FirstName, "^[a-zA-Z ]+$"))
result = "Name doesnot contain Numerical value";
Oleksandr Kulchytskyi 27-Dec-12 6:41am View
Yep, of course it must occur,
when you declare you class:
public class Customer : IDataErrorInfo you didn't provide any initialization of your class , so as a result if you check string.IsNullOrEmpty(FirstName), it it turn, it will return true!
And last one you must also inherit in INotifyPropertyChanged interface in your entities..., without such notification WPF wont update/display values properly...

Ohh yess. one more in for error notification (display func you must add appropriate style), so for textbox it must be:

<textbox grid.row="3" grid.column="1" margin="1,1,1,1" horizontalalignment="Stretch"
="" text="{Binding Path=FirstName, ValidatesOnDataErrors=true,UpdateSourceTriiger=PropertyChanged}">
Oleksandr Kulchytskyi 27-Dec-12 6:19am View
Not exactly what i'm expectiong for..
You said : "am getting an exception while following the method which using regex."
Where Exception???
Oleksandr Kulchytskyi 27-Dec-12 6:09am View
Ho to the link , i provided you with it , then download assembly from codeplex,
and add this assembly (reference to it) in you VS project
Oleksandr Kulchytskyi 27-Dec-12 6:03am View
Please provide me with exception cotent
Oleksandr Kulchytskyi 27-Dec-12 5:54am View
What do you mean ???
Total count of collumns on one sheet??
Or all columns (it's name )???
Oleksandr Kulchytskyi 26-Dec-12 15:44pm View
Which UI farmework did you use ??
WPF or WinForms???
Oleksandr Kulchytskyi 26-Dec-12 9:19am View
So for which purpose you need different instances of your web-service?
Oleksandr Kulchytskyi 26-Dec-12 9:17am View
So if my solution will be helpful ,please accept solution, and RATE this post ;)
Oleksandr Kulchytskyi 26-Dec-12 9:12am View
So if substitution of Dispatcher priority doesn't help, so we need to enforce Dispatcher loop with help of the code above in my solution
Oleksandr Kulchytskyi 26-Dec-12 9:05am View
Try to do the next, set the Dispatcher priority. ->
and now i'm trying to provide you with some helper code to force push messages in Dispatcher loop (wait few minutes)
Oleksandr Kulchytskyi 26-Dec-12 9:05am View
Try to do the next, set the Dispatcher priority. ->
and i now i'm trying to provide you with some helper code to force push messages in Dispatcher loop
Oleksandr Kulchytskyi 26-Dec-12 8:15am View
How to print in MVC telerik grid ... hmmm...
public ActionResult Index(){
ArrayList AL = new ArrayList();
DataClasses1DataContext contextData = new DataClasses1DataContext(); System.Data.Linq.ISingleResult Results = contextData.usp_DelBithdays_SELECT_BIRTHDATE_For_30_Days();
var qur = contextData.usp_DelBithdays_SELECT_BIRTHDATE_For_30_Days();
foreach (var sp in qur)
ViewBag.Collection= AL.ToArray(typeof(//yourData));

and somewhere in your VIEW you must assign ItemSource to ViewBag.Collection
Oleksandr Kulchytskyi 26-Dec-12 7:27am View
"I am also using two temp tabel for remark of record which is already loaded in ListView." - Why so complicated ?)
You can be easily bounded with only 1 table, in which you will write every action which affected table that you are observed.

Approach with SignalR by it nature will be robust and reliable!
But it requires some experience in web.
But one bigger advantage of it, with help of SignalR you can easily get rid of unneccessary stuff with observing temp tables and performing sync.

Lets quickly go through:
Your apps conneced to a SignalR hub, the for CRUD operation they will use this hub.
For example app on PC1 removes record with ID = 1, On Hub side SignalR performs delete operation , after delete was succeed, Hub will notify the rest of the client about delete operation , and all app on differ PF will receive notification abou that and do appropriate actions for sync ListView
Oleksandr Kulchytskyi 26-Dec-12 6:29am View
=)) Yep nice question =))
This is from serie where people asking which car is best =))
Each of it has their own prons and cons =)
As being C++ and C# developer, i can answer in the next key:
C# much easier for studie. In some case with C# some things musch easier to implement rather than C++.
And the last one , it's all depends, from purposes which you pursuit =)
Oleksandr Kulchytskyi 26-Dec-12 5:47am View
it seems very strange ....., i'll try to figure out what is wrong
Oleksandr Kulchytskyi 26-Dec-12 5:46am View
Thanks :)
I alway try to use TryParse methods, because it's a robust approach not so error prone like would be in case of usage Parse methods =)
Oleksandr Kulchytskyi 26-Dec-12 5:43am View
Which version of WP core ? 7.0 or 7.1??
Oleksandr Kulchytskyi 26-Dec-12 5:32am View
And one more , recently one person posted about Master-Detail MVVM in WPF
, so you can read it carefully to understant this approach
Oleksandr Kulchytskyi 26-Dec-12 5:23am View
Nice one !)
Oleksandr Kulchytskyi 26-Dec-12 5:13am View
Ok , i have updated my solution, so you can look at it, if it will help to U, please accept the solution and mark my answer ;)
Oleksandr Kulchytskyi 26-Dec-12 4:41am View
Sorry, but what the key and time period you are asking about ????
Oleksandr Kulchytskyi 26-Dec-12 4:09am View
My answer was concise, so as a result in property declaration i have ommited INPC(INotifyPropertyChanged mechanism) in WPF and MVVM it's need to be persisted anywhere , so without delraring this properties AS INP (in Models and ViemModel) it won't be work properly..
Oleksandr Kulchytskyi 26-Dec-12 4:05am View
My answer was concise, so as a result in property declaration i have ommited INPC(INotifyPropertyChanged mechanism) in WPF and MVVM it's need to be persisted anywhere , so without delraring this properties AS INP (in Models and ViemModel) it won't be work properly..
Oleksandr Kulchytskyi 26-Dec-12 3:42am View
=) Thanks, native strings :-)
Oleksandr Kulchytskyi 25-Dec-12 16:08pm View
Yep of course there are a lot of ways to do it, and maybe for learning purpose it would be more prefarable for you as a starting point, but i have formed my idea from consideration of extensibility and maintability of code.
What if in future decide to extend your app, and add one more tab which will access to db, and furthermore, if you familar with IoC and DI , for example you can easily replace your SQL repo with another one, for example Mongo Repo...
Oleksandr Kulchytskyi 25-Dec-12 16:01pm View
Ouch , could you please explain for which purposes you allow log in process in two different tabs of the same application??
Oleksandr Kulchytskyi 25-Dec-12 15:41pm View
Yep, completely agree with you, today i have tired to explain people that insertion command represented via string is a bad style, and this can lead to SQL injections...
Nice answer! My five :)
Oleksandr Kulchytskyi 25-Dec-12 9:27am View
So if my answer is compelling for you, please accept solution ;)
As concerns you problem (without having admin access), only one suitable advise can be useful for U- is to use port 80, which is open, otherwise for resolving access for other ports , unfortunately no way to resolve it whithout admin right.
Or i mistake, if you deploy it to IIS , and try to access for example from port 82. it might be work!)
Oleksandr Kulchytskyi 25-Dec-12 9:03am View
Empty = new EmptyPage[100];??? Provide community with full list of code!!!
Oleksandr Kulchytskyi 25-Dec-12 9:02am View
I don't believe you!! if(Empty[0]==null) must work!!!
Oleksandr Kulchytskyi 25-Dec-12 8:41am View
Did you try to do something ?) Or you expecting a list of sorces, which you can easily paste in VS ?))
Oleksandr Kulchytskyi 25-Dec-12 8:11am View
So, Does it help to you??
Oleksandr Kulchytskyi 25-Dec-12 5:56am View
Again not so correct question....
I have been involved in development of various ASP.NET apps.
Each of them use differ session state management mechanism.
Again and again i repeat that all depends...
In my own blog which i have written on ASP.NET , i use InProc mode , because:
- I store a little of data in session,
- I have no load balancer for it,
- My hosting provider exposes to me very powerful server(maybe this has no relevance for this question)
- Not all peages require sessions storage
So one conclusion, InProc mode much more faster but it requires more memor on the server
Oleksandr Kulchytskyi 25-Dec-12 3:39am View
Are envisioning to expose any code to community?)
Oleksandr Kulchytskyi 25-Dec-12 3:32am View
For the first time you don't have a problem, i mean did you envisioning such term as network latency or slow internet connection? This is a kind of gold rule to get rid of redundance overheads on UI thread..
So lets go back to you problem. Would you mind to show to community declaration of your lbBooks in XAML ?
I can mistake , but if you do not provide ItemSource property with some binding , the error could be hidden there, so for example:
<ListBox x:Name="lbBooks" ItemsSource="{Binding}">....

and another way is to do next <ListBox x:Name="lbBooks" ItemsSource="{Binding ObsBooks}">

where ObsBooks is ObservableCollection<book> ObsBooks {get;set;} in your window.

Also i recommend to you change DispatcherPriority.ApplicationIdle to Background
Oleksandr Kulchytskyi 24-Dec-12 7:55am View
Thanks for your answer, but if be honest i really know that if an objcets implements IDisposable, i need manually call Dispose method, or wrap it in scope of using block.
As concerns my question, i surf a lot in internet and got some confusion when i saw, that all articles which was written by MS, after finished of using Task object, do not call dispose method against instance of a Task.... or even didnt wrap in in using block. (I assume that most of MS developers knew about IDisposable interfale and resource disposing :) )
Thats why i have been asked this question..
Oleksandr Kulchytskyi 24-Dec-12 7:07am View
Sorry, obviously i inattentively read your question...
Oleksandr Kulchytskyi 24-Dec-12 4:19am View
Sorry ,I had no purpose to hurt you... my approach is below , under your first comment
Oleksandr Kulchytskyi 24-Dec-12 4:18am View
It can be done purely bu using XPath...

xmlDoc.SelectNodes("//dbo[xs:date(./FDate@text()) > xs:date('given date') and myParameter[text()='given parameter']]")
Oleksandr Kulchytskyi 24-Dec-12 4:12am View
Ohhhh, Recently i have been observing such tendency that there are a lot of lazy people who write some questions with only one intent is to get code which would work properly , it's very frustrates ....
Try to do the best of yourself , and only then , in case of failure, ask a question...
Oleksandr Kulchytskyi 24-Dec-12 3:30am View
No problem , make a reverse engineering from existing DB you can successfully replicate to code-first model, just look at this link ->

And the rest still remains the same as i wrote above!
Oleksandr Kulchytskyi 23-Dec-12 14:32pm View
Is it so hard to open MSDN and search all about IRequiresSessionState ?)
Namespace: System.Web.SessionState, Assembly :System.Web.dll.
Oleksandr Kulchytskyi 22-Dec-12 16:21pm View
You are welcome,Sorry but obviously, i have misspelled smth in that LINQ, just remove line -> let tmp=e, this is redundancy line of code =)
Oleksandr Kulchytskyi 21-Dec-12 10:49am View
Do you have any code ?)
Every time when peoples asking question like yours it's quite difficult to understand the problem behind the scene...
So please , sources in a studio )
And second one you don't specified type of EF is it Ef Code-first ? Which version?
Or somethink like that...
Oleksandr Kulchytskyi 21-Dec-12 9:09am View
Did you invoke Session.Abandon() method after completion all of the logic in logout button ??
Oleksandr Kulchytskyi 21-Dec-12 3:31am View
Nice solution especcially usage impersonation of user at first line in Main method.

But Have you ever seen the third overload of ServiceController ctor?)
If not , please check it on MSDN. It gives to you 1 additional parameter machine name , or in your case Ip address.

And the last one, Does any of remote machine located in the same domain ? If not , you approach will fail anyway.
Oleksandr Kulchytskyi 20-Dec-12 10:49am View
And i have forgotten to add url to call that service.
In your case it will remains the same: http://localhost:2664/FrontService.svc/Login?UserName=max
Oleksandr Kulchytskyi 20-Dec-12 9:08am View
Hi , Did you use the in-process session state mode ???
When the Session State Manager removes a session state object that resides in the cache, the HttpCache manager will call any registered callbacks. In effect, this behavior raises the Session_OnEnd event handler. (IN CASE of in-process session state mode!!!)
Oleksandr Kulchytskyi 19-Dec-12 3:35am View
Well, personally for me,it would be preferable to work in Wpf MVVM with conjunction of third-party Library called MvvmLight (Galasoft.MvvmLight.* namespaces), by its convenience and exposing many helpfull features like Mediator , Notification, Threading. You can get it via NuGet package manager.

So let begin with our domain model.
//as far as you want to perform various validations against model, our domain model inherits IDataErrorInfo interface
public class PersonModel: GalaSoft.MvvmLight.ObservableObject,IDataErrorInfo
private int _id;
public int Id
get{return _id;}
set { if(_id!=value){_id=value; base.RaisePropertyChanged(()=>Id);}}
... other properties was omitted for brevity

ViemModel part:

public sealed class PersonViewModel:GalaSoft.MvvmLight.ViewModelBase
private PersonModel _curPer;
public PersonModel CurrentPerson
get{return _curPer;}
_curPer=value; base.RaisePropertyCahnged(()=>CurrentPerson);

private ObservableCollection<PersonModel> _perList;
public ObservableCollection<PersonModel> PersonList
get{return _perList;}
_perList=value; base.RaisePropertyCahnged(()=>PersonList);
// other stuff(Commands and so on) was omitted for brevity.

And last , you xaml:

<stackpanel datacontext="{Binding CurrentPerson}" orientation="Vertical">
<textbox text="{Binding Id,Mode=TwoWay}">

<ListBox ItemsSource="{Binding PersonList}" DisplayMemberPath="Id"
SelectedItem="{Binding CurrentPerson,Mode=TwoWay}"/>
Oleksandr Kulchytskyi 2-Oct-12 2:23am View
All depends!!
WinForms has no such powerful UI capabilities like WPF.
And i'm sure that UI of 2012 has been built on top of WPF.
Oleksandr Kulchytskyi 7-Sep-12 3:49am View
Well actually i'm using static bound functionality, and reffer to one assembly , which in turn use late/rutime binding.
Oleksandr Kulchytskyi 5-Sep-12 7:55am View
thx! Yep, it's really work with hotfix.
You are my saviour!)
Oleksandr Kulchytskyi 5-Sep-12 7:45am View
Sorry, but about which hotfix, you have mentioned above ???
I haven't encountered any suggestion about hotfix.
Could you please share link , where you have been read about that??
Oleksandr Kulchytskyi 23-Aug-12 14:24pm View
I fully agree with you. The code looks much cleaner.
But if think in way of performance consideration, if one thread wants to read some resource , but another has already locked it resource and tries to write some data, reader thread must wait until another thread will complete its activities agains this resource.
In case of RWLS we locked only specific action types (write , read)
Oleksandr Kulchytskyi 23-Aug-12 13:37pm View
Yep, i know such locking construction but i one arcticle which is related to C# development, i've read that it would be more polite to replace lock(..){} to more efficient ReaderWriterLockSlim technic.
So as a result, i've been interesing in using of ReaderWriterLockSlim.
Oleksandr Kulchytskyi 21-Aug-12 3:00am View
returnTypes[Type.GetType(item.Attribute("service").Value)] = Type.GetType(item.Attribute("contract").Value);
Oleksandr Kulchytskyi 21-Aug-12 3:00am View
As usual =) Your answers are perfect !)
Thanks a lot for you help. For now i have clear imagination about my issue and i know how to handle it. Again , thanks)
Oleksandr Kulchytskyi 20-Aug-12 8:28am View
In such way we define and assign length of ipTemp member of IntPt type. to define OS bitness version of OS (32,64)
Oleksandr Kulchytskyi 15-Aug-12 11:23am View
yes , of course , i'm a bit of careless today , so instead of name OrderByType i called it Order in method above.
Oleksandr Kulchytskyi 15-Aug-12 10:57am View
yep ,sorry for incorrect piece of code.

public ActionResult OrderByType(Models.PrePurchaseSearch search)
if (!ModelState.IsValid)
return Json(new
Result = "ERROR",
Message = "Form is not valid! " +
"Please correct it and try again."
return Json(db.RoomData).Where(x=>x.type==search.Type);
catch (Exception ex)
return Json(new { Result = "ERROR", Message = ex.Message });
return Index();

But with it code my $.post method fails, i dont know why.
In debug i go through code and ensures that query to db work properly and retreives appropriate data.
I work with EF 4.3.1 , and have chhosen Code-First approach.
Oleksandr Kulchytskyi 15-Aug-12 10:46am View
Yep, I'm in favor of Razor.
So for now i've resolved this.
Thanks for your help.
Oleksandr Kulchytskyi 15-Aug-12 10:22am View
No , my select control looks like this:
Movie Type
<select id="prePurchaseType" name="Type">
<option value="0" selected="selected">Time to start</option>
<option value="1">Highest prize value</option>
<input type="submit" id="btnSearch" value="Search" />
Oleksandr Kulchytskyi 15-Aug-12 10:22am View
No , my select control looks like this:
Movie Type
<select id="prePurchaseType" name="Type">
<option value="0" selected="selected">Time to start</option>
<option value="1">Highest prize value</option>
<input type="submit" id="btnSearch" value="Search" />
Oleksandr Kulchytskyi 15-Aug-12 9:47am View
The problem hides behind the passing of value which user choose in html select control
to HTML.Action method ...
HTML.Action("Search","Models",new {country =???}
Oleksandr Kulchytskyi 13-Aug-12 15:44pm View
I think it's very specific issue, so as a result try you own to resolve it via self implementation.
Oleksandr Kulchytskyi 13-Aug-12 15:35pm View
Try to use ASP.NET WebApi in hot favor of it's flexibility and scalability , it can gives to you more control over JSON , and standart HTTP protocol.
As concersn your issue , show implementation of your method, how you convert it to JSON ? At first sight , with Rest declaration of your WCF, it seems like it fine.... but what behind the scene ?
Oleksandr Kulchytskyi 11-Aug-12 13:25pm View
I can recommend to use use WebApi , instead of old-palain WCF Rest.
Try to use this brand-new framework , and i think you will be astohished with it.
You can set differ message formatters the in few lines of code, set necessary routing , etc.
Oleksandr Kulchytskyi 11-Aug-12 13:21pm View
As being favor in ITextSharp , i recommend to you use this open-source library!
Oleksandr Kulchytskyi 11-Aug-12 9:10am View
Nothing great, sorry, i have been impatiently read article , and at first sight i got it like MS allows development to a desktop in express edition of vs 2012
Oleksandr Kulchytskyi 10-Aug-12 11:01am View
it's very interesting !) Thanks again!)
Oleksandr Kulchytskyi 10-Aug-12 10:49am View
whoa) It's great news)) From the latest article which i have read , Microsoft restricted dev not only in express for desktop but in general, including dev only for metro =)

But that article changed my knowledge =)I have seen that it still remains in paid versions of VS2012!!)
Tahnks a lot !)
Oleksandr Kulchytskyi 10-Aug-12 10:49am View
whoa) It's great news)) From the latest article which i have read , Microsoft was restrict dev in express for desktop , including dev only for metro =)
But that article changed my knowledge =)
Tahnks a lot !)
Oleksandr Kulchytskyi 10-Aug-12 10:43am View
Thanks for your answer =)
But this is not exactly what i'm interesting in.
I know what it is a WPF, XAML , WinForm and how these frameworks looks like and so on =)
Also i know that WPF in most cases pushed off WinForms from a play-chase, Microsft itself heavily uses the WPF technology in their own apps.

For the dev , who being confident in XAML , microsoft opened a wide range for development: WinPhone 7,7.5 + as far as i know will remain in upcoming WP 8;
Wpf - uses Xaml, and in core of Metro UI you can still find a XAML =)
So the question still relevant =) Core of UI in VS 2012 relies on WPF ?)
Oleksandr Kulchytskyi 8-Aug-12 8:34am View
Well exactly i need to check access to following string :
Ldap + "://" + ldapServer + fulldomain.trim() + ":" + port.trim() + "/"
Oleksandr Kulchytskyi 8-Aug-12 8:22am View
Yep, thanks for it.
But it require a login and password.But in my case, i can only provide it with
server name, full domain name and port.
So this is not exactly what i need.
Oleksandr Kulchytskyi 1-Aug-12 15:55pm View
Thanks for a link, but i have already read this article, and this article didn't preview any unstandart routing templates, only standart routing , like this:{controller}/{action}/{parameters}. This is not exactly what i need...
Oleksandr Kulchytskyi 30-Jul-12 8:31am View
Models.PhysicianInfo2.Speciality property that, represents physician info specialties, it could consists from one or more items.
Oleksandr Kulchytskyi 30-Jul-12 8:28am View
partially, i resolved my issue , but i encountered with another problem related to aggregate exception

Fixed query looks like below:

var item2 = (from item in _context.Physician.Include("PersonalInfo").Include(x => x.PhysicianSpecialty).Include("PhysicianSpecialty.Speciality")

let specialities = (from spec in _context.PhysicianSpecialty
where spec.PhysicianID == item.PhysicianID
select spec.Specialty)

select new Models.PhysicianInfo2()
NPI = item.NPI,
Email = item.PersonalInfo.Email,
FirstName = item.PersonalInfo.FirstName,
LastName = item.PersonalInfo.LastName,
MiddleName = item.PersonalInfo.MiddleName,
Prefix = item.PersonalInfo.Prefix,
Suffix = item.PersonalInfo.Suffix,
Speciality = (from subItem in specialities
select subItem.Name).Aggregate((a, b) => string.Format("{0}, {1}", a, b)),
Institution = string.Empty

but error appears:

LINQ to Entities does not recognize the method 'System.String Aggregate[String](System.Linq.IQueryable`1[System.String], System.Linq.Expressions.Expression`1[System.Func`3[System.String,System.String,System.String]])' method, and this method cannot be translated into a store expression.
Oleksandr Kulchytskyi 25-Jul-12 9:03am View
I have been looking into some push notification services , but for this moment i didn't find any framework on NET...
As option one person advices to me, look into Zend-Framework, but it's on PHP...
I look for some managed solution on NET
Oleksandr Kulchytskyi 17-Jul-12 7:22am View
Yep, sorry for my incorrectness, i'm really writing to file =)
Oleksandr Kulchytskyi 1-Jul-12 8:26am View
public IQueryable GetJob_Allowance()

return this.ObjectContext.Job_Allowance.Where(ds => ds.Job_ID>=1 && ds.Job_ID<=3);
Oleksandr Kulchytskyi 29-Jun-12 14:41pm View
Yep, i didn't think about breaking capabilities of .NET interoperability in differ OS. Again, thanks =)
Oleksandr Kulchytskyi 29-Jun-12 9:28am View
Thanks for your reply.
I also look forward for similar solution of using some kind of collection , where i could store entered data and check for duplication.
But also i'm interesting other solution, for example of using native WinApi(P/Invoke), which can help handle last entered line to console)
But anyway, thank for your time)
Oleksandr Kulchytskyi 18-Jun-12 11:20am View
Only WsHttpBinding, NetTcpBinding and NetNamedPipeBinding support sessions.
So you can look forward to implement sessioning environment using WSHttp...
Oleksandr Kulchytskyi 17-Jun-12 4:03am View
Ok =) Sorry for my inattention. I will try to move forward, to find out solution , which you expect.
Oleksandr Kulchytskyi 15-Jun-12 13:09pm View
Oleksandr Kulchytskyi 11-Jun-12 15:48pm View
My 5 to your answer , As always, you are giving a very informative answers and advices. Codeproject must proud , that have such experienced people like you !
Oleksandr Kulchytskyi 11-Jun-12 15:46pm View
I do not use Thread.Abort. This can corrupt workflow state.
I use CancellationtokenSource and IsCancelled property for monitoring whether cancellation is requested,
thread run in infinite loop and periodically , say one time in 5 minute must run process.
Oleksandr Kulchytskyi 8-Jun-12 7:14am View
Do you call from your service any unmanaged code/resources??
Oleksandr Kulchytskyi 7-Jun-12 1:44am View
Yep sorry)) it's my fault. I wrote this code on the fly)
Oleksandr Kulchytskyi 6-Jun-12 3:21am View
What are you talking about???
Maybe you mean how to host WCF service in WPF application???
Oleksandr Kulchytskyi 5-Jun-12 4:44am View
Graceful implementation, my 5 to U!)
Oleksandr Kulchytskyi 5-Jun-12 4:24am View
What about timeouts for sending/receiving data ??
Oleksandr Kulchytskyi 5-Jun-12 4:10am View
Solution above is a very tough for implementation, but very robust in practice.
Also it's possible to implement such functionality via WinApi method
WTSEnumerateProcesses, implementation of logic by using this WinApi methods seems much easier. But I'm not use it in practice ;)
Oleksandr Kulchytskyi 4-Jun-12 10:20am View
Since invention of Vista OS, all service , which running in Local System account, run in separate session, and has differs from your currently logged on user desktop. So you could change service account to run in appropriate user enviroment.
Oleksandr Kulchytskyi 4-Jun-12 8:08am View
On which account NT service running? (Local system / or from user name)

And on which OS it running?
Oleksandr Kulchytskyi 3-Jun-12 3:18am View
Man, i already did it in Solution 1 , look at second code snippet!!
As you can see , i wrapped yours StreamReader objstream in scope of using(..){...} . After performing file reading, streamreader will automatically close file handle.

Read carefully about using on MSDN

Also i could add that, if you disassemble my code, you will find,
that using observed in next manner

StreamReader objstream=null;
objstream=new new StreamReader(Properties.Settings.Default.url);
richTextBox1.Text = objstream.ReadToEnd();
objstream.Dispose(); //in this case Dispose method responsible for closing file handle.
Oleksandr Kulchytskyi 2-Jun-12 10:29am View
Yes, of course you will get an error if you performs doubleclick on richtextbox1.
If we will follow your logic, in event handler on button1 click, you create streamreader object,with help of which you read the content to richtextBox1, and forget to close file handle.

So, when you tries to save data, you will get an error, because the file handle
on which you tries to perform save action wiil fail , because it had already been opened. so as a result do not forget to close a handle on opened streams!!!!
Oleksandr Kulchytskyi 2-Jun-12 3:30am View
This NT service was written by you? If yes , a you injected any logging capabilities?
If not, move in such way which was described by Mehdi Gholam.
Oleksandr Kulchytskyi 1-Jun-12 17:59pm View
Is it any unclear moments ?
Oleksandr Kulchytskyi 1-Jun-12 17:54pm View
=)) You should implement some class whith this method)

public static class NativeMethods
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
Oleksandr Kulchytskyi 1-Jun-12 17:51pm View
=) Now issue became more clearly)
NativeMethods is a third-party class , which is not related to .NET environment.
Oleksandr Kulchytskyi 1-Jun-12 17:48pm View
Yep ) it's an interesting article. Thanks for share link)
Oleksandr Kulchytskyi 1-Jun-12 17:45pm View
I'm glad that i helped you ;)
Oleksandr Kulchytskyi 1-Jun-12 16:12pm View
Please, provide us with your internal implementation of SendMsg method.
Oleksandr Kulchytskyi 1-Jun-12 15:20pm View
Great explanation =) I see you are very comfortable in server\client architecture, especially in net sphere.
It's a big pleasure to read you posts and solutions =)
Oleksandr Kulchytskyi 1-Jun-12 14:15pm View
Using word periodically, i mean that client needs the data in interval of 3 to 1 second.
Oleksandr Kulchytskyi 1-Jun-12 11:02am View
Величезне дякую ;-))
Oleksandr Kulchytskyi 1-Jun-12 11:01am View
Yep, that is an amazing and astonishing answer =))
Thanks a lot to you =) My 5 points to you!!!!
Oleksandr Kulchytskyi 1-Jun-12 10:45am View
Thanks a lot Tim, you gave me a useful links !!! my 5 to you ;)
Oleksandr Kulchytskyi 1-Jun-12 8:01am View
SharpZilLib have ablity to compress multiple folders in parent.
Oleksandr Kulchytskyi 1-Jun-12 7:26am View
Are you sure that The OpenFileDialogue opens the file ?))
As far as i know, it just return path of picked file.
The problem is not in that.
Better look how he is using StreamReader object.
Oleksandr Kulchytskyi 1-Jun-12 3:59am View
In which format your data preserves??
Oleksandr Kulchytskyi 1-Jun-12 3:39am View
You can do it by using xml serialization mechanism in NET environment. See link
Oleksandr Kulchytskyi 1-Jun-12 3:16am View
Well, it seems like your remote machine doesn't have ability to connect remotely via rdc. try to handle such issue by settings appropriate settings to rdc.
Oleksandr Kulchytskyi 31-May-12 15:54pm View
Please provide us with some code fragment.
It's very difficult to figure out issue only with help of words....
Oleksandr Kulchytskyi 31-May-12 15:51pm View
It's great that you mentioned about string concatenations.
Often it became a big punch for beginners, while they operate with string data.
Oleksandr Kulchytskyi 31-May-12 12:19pm View
Yep , sorry it is my fault.
Depend on platform invoking from Advapi32.dll DuplicateToken method can return both int and bool.
In int implementation in case of success it returns 0;
So you can replace definition to follow:
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern int DuplicateToken(IntPtr hToken,int impersonationLevel,out IntPtr hNewToken);

or just change in code this snippet
if(DuplicateToken(admin_token, 2, out dupToken) != 0)
to this
if(DuplicateToken(admin_token, 2, out dupToken))
Oleksandr Kulchytskyi 31-May-12 9:24am View
What about m_timer.Dispose() method?)
Read MSDN carefully) As far as you must know,in all classes which implement IDisposable must you must manually invoke Dispose() or incorporate it in statement using(m_timer) { ... }. This rule relate to classes which havn't Finalizators.
Oleksandr Kulchytskyi 30-May-12 11:13am View
Thanks for useful link , it content seems to be very helpful.
I am already using JpegBitmapEncoder, but i had some doubts about that)
Oleksandr Kulchytskyi 30-May-12 10:54am View
Yep, i can.
Undo() is not the same as CloseHandle. CloseHandle, release unmanaged resources which you created with LogonUser().

#region consts

#region Windowns API
[DllImport("advapi32.DLL", SetLastError = true)]
public static extern int LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern bool CloseHandle(IntPtr handle);

[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern bool DuplicateToken(IntPtr hToken,int impersonationLevel,out IntPtr hNewToken);

IntPtr admin_token = default(IntPtr);
IntPtr dupToken = default(IntPtr);
WindowsIdentity wid_current = WindowsIdentity.GetCurrent();
WindowsIdentity wid_admin = null;
WindowsImpersonationContext wic = null;
string[] split = new string[1];
split[0] = "\\";
string[] temp = ServerName.Split(split, StringSplitOptions.RemoveEmptyEntries);
string domain = String.Empty;
string userName = ServerUserName;
string password = Password;
if (LogonUser(userName, domain, password, LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, ref admin_token) != 0)
if(DuplicateToken(admin_token, 2, out dupToken) != 0)
wid_admin = new WindowsIdentity(dupToken);
wic = wid_admin.Impersonate();
// do your thing
catch { } // if case of you do something with excepions
if (wic != null)

Oleksandr Kulchytskyi 30-May-12 9:55am View
Nice solution, but you are not pointed to a few crucial moments.
First of all , admin_token needs to be released by calling WinApi method CloseHandle.
Second one, WindowsImpersonationContext implements IDisposable, so you should call Dispose() method.