.net

Dependency injection with unity in a class library project

笑着哭i 提交于 2021-02-18 17:35:12
问题 I am new with the dependency injection pattern. I'm a little confused about few things. Scenario: I have a class library project called 'MailCore'. This project has interfaces and classes that perform all email sending stuff. I have an MVC project called 'The site'. It uses the 'MailCore' project to send email. I have Unity in this project and the UnityContainer is registered and things are working fine. I also have another class library library project called 'SiteRepo'. Sometimes, to

A call to SSPI failed, see inner exception when running the call a second time?

五迷三道 提交于 2021-02-18 17:10:30
问题 I have the following code : public GetUserDataResponse GetUserDataFromService(X509Certificate2 certificate) { ChannelFactory<MyApp4SITHSService.IMyApp4SITHSServiceContract> factory = new ChannelFactory<MyApp4SITHSService.IMyApp4SITHSServiceContract>("NetTcpBinding_IMyApp4SITHSServiceContract_Certificate"); MyApp4SITHSService.IMyApp4SITHSServiceContract service; GetUserDataResponse response; factory.Credentials.ClientCertificate.Certificate = certificate; //factory.Credentials.UserName

A call to SSPI failed, see inner exception when running the call a second time?

ⅰ亾dé卋堺 提交于 2021-02-18 17:07:41
问题 I have the following code : public GetUserDataResponse GetUserDataFromService(X509Certificate2 certificate) { ChannelFactory<MyApp4SITHSService.IMyApp4SITHSServiceContract> factory = new ChannelFactory<MyApp4SITHSService.IMyApp4SITHSServiceContract>("NetTcpBinding_IMyApp4SITHSServiceContract_Certificate"); MyApp4SITHSService.IMyApp4SITHSServiceContract service; GetUserDataResponse response; factory.Credentials.ClientCertificate.Certificate = certificate; //factory.Credentials.UserName

Geolocation in WinForms application

我与影子孤独终老i 提交于 2021-02-18 12:58:12
问题 I want to create a WinForms app that can detect location just like a web browser would using the javascript function navigator.geolocation.getCurrentPosition(showPosition); Is there some way to do this in WinForms directly? I thought that I might be able to use the WebBrowser control to do this but I don't believe this supports Geolocation (unless someone knows otherwise?) Apparently the Gecko browser does support gelocation but this is not an option for me because client may have a different

How to Select All with a One to Many Relationship Using Linq

情到浓时终转凉″ 提交于 2021-02-18 12:57:32
问题 I have two tables: CREATE TABLE Thing ( Id int, Name nvarchar(max) ); CREATE TABLE SubThing ( Id int, Name nvarchar(max), ThingId int (foreign key) ); I want to select all Things with a listing of SubThings and set them to a ThingViewModel. The Thing ViewModel is simple: public class ThingViewModel { public int Id { get; set; } public string Name { get; set; } public List<SubThingViewModel> SubThings { get; set; } } The SubThingViewModel is: public class SubThingViewModel { public int Id {

Null coalesce not working in LINQ query

99封情书 提交于 2021-02-18 12:45:31
问题 Take this: int? item1 = null; int? item2 = null; someObjectList.Where(x => x.SomeItem1 == (item1 ?? x.SomeItem1) && x.SomeItem2 == (item2 ?? x.SomeItem2) ); Where someObjectList is not empty and SomeItem1 and SomeItem2 is null in all the objects in the list. Why is it returning nothing? EDIT: My Code: public void GetPlacementsByMaterial(long clientMaterialID) { ClientMaterial clientMaterial = ((ApplicationEntityModel)NavigationItem.ObjectContext).ClientMaterial.FirstOrDefault(x => x

Null coalesce not working in LINQ query

穿精又带淫゛_ 提交于 2021-02-18 12:45:08
问题 Take this: int? item1 = null; int? item2 = null; someObjectList.Where(x => x.SomeItem1 == (item1 ?? x.SomeItem1) && x.SomeItem2 == (item2 ?? x.SomeItem2) ); Where someObjectList is not empty and SomeItem1 and SomeItem2 is null in all the objects in the list. Why is it returning nothing? EDIT: My Code: public void GetPlacementsByMaterial(long clientMaterialID) { ClientMaterial clientMaterial = ((ApplicationEntityModel)NavigationItem.ObjectContext).ClientMaterial.FirstOrDefault(x => x

Asynchronous Google File Upload with Progress Bar WPF

时光总嘲笑我的痴心妄想 提交于 2021-02-18 12:36:06
问题 I am uploading to Google Cloud Storage using a service account. I need to be able to display the progress of the upload in the WPF UI. Now, Whenever I try to update the ProgressBar.Value, it's not working, but when I just have the bytesSent written in Console, I can see the progress. public async Task<bool> UploadToGoogleCloudStorage(string bucketName, string token, string filePath, string contentType) { var newObject = new Google.Apis.Storage.v1.Data.Object() { Bucket = bucketName, Name =

How to open window system menu on right click?

与世无争的帅哥 提交于 2021-02-18 12:24:06
问题 I have a borderless splash screen form displaying loading progress and containing Minimize and Close buttons (something similar to splash screens seen in Office 2013). I would also like to provide system menu of the window which opens on right click anywhere in the form. Currently I'm achieving opening the menu by sending keys Alt+Space . System.Windows.Forms.SendKeys.SendWait("% ") 'sending Alt+Space With this approach, window system menu always opens in top-left corner of the window. Is

Async/await vs Task.Run in C#

假装没事ソ 提交于 2021-02-18 12:16:25
问题 I am just new to this world of asynchronous stuff. Please bear with my lack of knowledge. It is said when a method encounters await ... " It tells the awaitable to run the remainder of the method when it completes, and then returns from the async method. " I did not get this part. So does it mean the method still keeps on running synchronously and waits till the awaitable returns and then proceeds with the rest of the method? If not please explain then why Task.Run is needed to run a method