Dependency Injection in WPF - A TimCo Retail Manager Video

  Рет қаралды 63,249

IAmTimCorey

IAmTimCorey

Күн бұрын

** TimCo source code now at: www.iamtimcorey.com/courses/b...
Full Courses: www.iamtimcorey.com
Mailing List: signup.iamtimcorey.com/
In this video, we add dependency injection into our WPF project using Simple Container, which comes with Caliburn Micro.
One-off tutorials are awesome but they aren't the only thing you should be doing to learn C#. Another vital part of learning is learning how to put it all together. This interactive course is all about putting the pieces together. You can watch each video on its own or you can watch them in order and see a bigger picture. The choice is yours.
This course focuses on real-world development. As such, we are simulating that we work for TimCo Enterprise Solutions on a brand new product, the TimCo Retail Manager. Just like in the real world, we are starting out with one set of requirements but know that over time they will change.

Пікірлер: 163
@michaelhaddad2190
@michaelhaddad2190 5 жыл бұрын
Two a week! AWESOME! Thank you Tim!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome. Just don't get used to it every week. I don't have the time to produce three videos a week (two is a stretch). I do try to throw a bonus in if a lesson is short or if I have to separate out a piece though. I'm glad you enjoyed it.
@sc100200090
@sc100200090 4 жыл бұрын
Definitely the first time I have found a valuable treasure clarifying DI! Thanks again!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Glad it was helpful!
@longuinni
@longuinni 5 жыл бұрын
Really nice video. The world needs more people like you!! Thank you for making that series, I'm learning a lot.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thank you!
@onyebuchiboss
@onyebuchiboss 5 жыл бұрын
Just when I thought I was intermediate in coding, I watch Tim's Video and Boom, it reminds me I am still learning lmaoo. Thanks Tim!, I really appreciate this.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
We are all still learning. DI is really an advanced topic so I don't think it is a threat to your intermediate understanding of C#. Keep up the good work.
@onyebuchiboss
@onyebuchiboss 5 жыл бұрын
@@IAmTimCorey Thanks Tim!
@donybg
@donybg 5 жыл бұрын
Same thing here. And most often than I care to admit, I realize I was doing it all wrong.
@paulmoyers791
@paulmoyers791 4 жыл бұрын
This course has been absolutely incredible! I watch the majority of these videos before I had even decided to follow along. I have learned more in just the first 5 videos than any other training sessions I have completed thus far. I finally understand how to properly use a constructor. Keep up the great work. I am really enjoying learning from you.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Awesome!
@koffibanan3099
@koffibanan3099 5 жыл бұрын
Thanks Tim! Soo much to learn still, it's hard to actually really start going. Love this series.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I am glad you are enjoying it.
@talkathiriify
@talkathiriify 5 жыл бұрын
Excellent Job I really appreciate all your tutorials, Thank you very much
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@datahead6803
@datahead6803 5 жыл бұрын
Thank you Tim. This is way over my head but that's why I'm watching. I'm coding along with you so I can have an awesome example for other projects. I really appreciate the videos.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Sometimes just coding along helps things click. It definitely pushes your knowledge forward faster than just watching. Keep up the good work.
@harag9
@harag9 5 жыл бұрын
@@IAmTimCorey I find coding along better than copy and paste or downloading source, so a 30 min vid is a little longer due to pausing as I find it easier to type and then listen to the explanation :)
@bedocan1
@bedocan1 5 жыл бұрын
Thank you very much Tim, you are a great tutor.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@bencejuhasz2938
@bencejuhasz2938 4 жыл бұрын
Thank you again, Tim! You help me a lot!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@vrace271
@vrace271 5 жыл бұрын
Brilliant stuff once again!!!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thank you!
@patrickdaems6558
@patrickdaems6558 5 жыл бұрын
Another Great Video Thx Tim. This are my first steps (babysteps at first ;) ) in DI
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are most welcome. Thanks for watching.
@talkathiriify
@talkathiriify 5 жыл бұрын
Very nice tutorials Thank you very much
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@AntonyJudes
@AntonyJudes 5 жыл бұрын
Something new i learnt. thankyou Tim. somewhat hard to understand, but in future sessions, i may get understand. i did simply what u did. thats all. Thank you.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
That's a good start. Do it a couple times and use it a bit and you will get the hang of it.
@nasben66
@nasben66 5 жыл бұрын
Thank you Tim for this nice video, I would appreciate it if at the end of the video tell us what's coming next so we can be prepared.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'm working on getting this in place. Thanks for the suggestion.
@offiryehezkel4802
@offiryehezkel4802 3 жыл бұрын
Hi Tim, Dont know if this was asked before, but how do you use ActivateItem on a ViewModel that has DI ? For example, when changing Screens (User Control) after login screen i do this: _mainViewModel.ActivateItem(IoC.Get()) or _mainViewModel.ActivateItem(new DashboardViewModel()) Both arent working, It asks for the parameter in the constructor of DashboardViewModel... But my DashboardViewModel has a DI, so it doesn't work.. . Any suggestions ? Thanks. hope you will replay..
@jerellsmith7395
@jerellsmith7395 3 жыл бұрын
I was able to get WPF working as detailed in video. Now I am trying to implement same pattern in Web MVC but having trouble using the access token, the api helper is null when I try to log in. Any advice?
@UrzaRage778
@UrzaRage778 3 жыл бұрын
Hey Tim! It's possible I'm jumping the gun here, but at 9:30 you are talking about the Configure method and end up declaring things like the WindowManager and EventAggregator... What would be the case in which you would use something different? Or are you by in large just going to be using the Caliburn Micro instances? I assume if for some reason we really wanted to, we could use our own or another library that has a WindowManager/EventAggregator that implements IWindowManager/IEventAggregator?
@safaenet
@safaenet 2 жыл бұрын
great video. Question 1: what if we want to call an instance of ShellView from another View? We will have to create an instance of ShellViewModel, right ? For example: var viewModel = new ShellViewModel(/*here is my ploblem /*); (new WindowsManager()).ShowDialog(viewModel); Question 2: what if we want to pass also another data (e.g: int fooValue) to ShellViewModel using constructor ? should we change the constructor definition to public ShellViewModel(ICalculations calculations, int foo) ?
@glenroyscott7285
@glenroyscott7285 3 жыл бұрын
Hi Tim, excellent tutorial as usual. However i am having an issue with caliburn micro simplecontainer DI. Its singleton implementation does not allow me to change from HttpClient to HttpClientFactory implementaion. I am assuming there is a way to implement it in the simplecontainer DI, but with all my research i cannot how to. Secondly, in my frustrations, i decided to change from simplecontainer and use netcore's DI system using the IServiceCollection . But once again another roadblock, i dont know how configure the DI for it to work in Bootstrapper. Please advise how i can implement any of the above solutions so that i can use HttpClientFactory in application. Thanks in advance.
@Deekudla
@Deekudla Жыл бұрын
Great series. I am lucky to be your follower. I have a question. In this series did you managed to talk about "logging" ? which is one of the key in any enterprise application development? I hope you have covered in upcoming videos in this series.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
I don't remember if I added logging or not, but here is a video on how to implement logging in .NET: kzbin.info/www/bejne/lZrVqo2uq52Frtk
@Otonium
@Otonium 4 жыл бұрын
A link to the playlist would help a lot, sometimes one skip a video and it would be very handy if we can have that in the description. Thanks!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Here's the link to the playlist. I'll see what I can do about adding it to videos: kzbin.info/aero/PLLWMQd6PeGY0bEMxObA6dtYXuJOGfxSPx
@kaneaqkeller
@kaneaqkeller 5 жыл бұрын
Hey Tim, at 29:50 when you run the solution, how exactly does the ShellViewModel with the custom constructor (with ICalculations) get accessed? Wouldnt the undefined default constructor be called to create an instance of the ShellViewModel instead? I'm do not understand the link from OnStartUp to constructing ShellViewModel(ICalculations).
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Actually, once you define one constructor, there no is no longer a default constructor. If you wanted an empty constructor (like the default is), you would need to define that specifically as a separate, overloaded constructor. In this case, though, dependency injection is looking at the constructors and identifying which one(s) it can fully satisfy. It uses the one with the most items it can satisfy. It finds our only constructor, identifies that it needs an ICalculations object, knows it understands how to instantiate one of those, does so, and passes in that object to the correct constructor.
@obscureorigin2642
@obscureorigin2642 5 жыл бұрын
Hi Tim! I'm building an application of my own for learning purposes after following through your TournamentTracker series and the WPF add-on course for that. I've come to a point where I want to start adding unit tests. To make that easier I learned about DI. Now I have a fairly similar case to what you showed in this video where I have a Calculator class, but mine is placed in the Class Library. Whenever I try to use DI for my Calculator class in the WPFUserInteface project or for the ViewModel classes in my WPFUserInterfaceTests project, I'm getting the error "No suitable constructor was found." I'm guessing this is because all the DI-related methods that are configured in Bootstrapper are protected? I noticed that in your Autofac video you are setting up DI so that classes from your class library are involved as well. Is SimpleContainer only usable in the WPF project and if so how should DI be setup so that it can be used across the solution in Unit Tests for example?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I set up SimpleContainer to pull from the class library here as well. I think it is just a configuration issue that you are experiencing.
@DivakarRaj
@DivakarRaj 2 жыл бұрын
Hi Tim, A query which I wanted to ask. How do you identify the appropriate Nuget packages and third party libraries to use ? For example, in this video, how do we identify that Caliburn Micro is the best library for our purpose. Does it come with experience, or do we need to refer various forums or do we need to try out various third party libraries before hitting upon the one which suits our needs
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Practice. When you learn about a library, try it out. See if it works well, then see what needs it fills. Then, write that down. When you r next project comes around, and you find that you have a need, see if you have found a package that fulfills that need. Just be careful that you don't have solutions in search of a problem. Only after you know you have a need should you look for a solution. Otherwise, you will be taking on dependencies without enough benefit.
@harag9
@harag9 5 жыл бұрын
Think I'm starting to follow along, with the shellviewmodel I'm so use to passing a parameter "container" to it etc. was a little confused when this worked and I didn't pass in any container into the class constructor. Guess that's the "Caliburn Micro" doing it's thing. - Is Caliburn Micro just for WPF - if so, what is the alternative for WinForms - is that AutoFac, Ninject - not really looked into these. Again thanks for another great episode!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
The container is the tool that actually creates the instances. We don't need to pass it around unless we want to manually dip into the container. As for Caliburn Micro, it is specific to WPF. Normally when I use a DI system, I use AutoFac (I have a couple videos on it on this channel). We will use AutoFac in the WebAPI layer.
@harag9
@harag9 5 жыл бұрын
@@IAmTimCorey Thanks for the response Tim, much appreciated. I think I've seen an Autofac video of yours a while ago but don't really do much "new" projects to use it and learn it. I'll have to find it and watch it again.
@benedictjohn848
@benedictjohn848 5 жыл бұрын
Thanks Tim for a very good tutorial. Could you please make some video about how to use passwordbox properly or how to create a very secure login for desktop applications. Thank you.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Well, we will be logging into the API from this WPF application, so you should see all of that.
@vijithsreevalsam7979
@vijithsreevalsam7979 2 жыл бұрын
Dear Tim, You are really a best teacher ever seen. thank you so much for these valuable content . I have a question always comes in my mind. May be a stupid question . how do you know this . these question always comes to my mind when I saw any code . How you know this, I need to add this code here . I need to use this instance here. etc.. I learned most basic things in c# . including OPPs. but when I see these new libraries . really wonder how you made that. yes you might say documentation.. but most time for me its almost no connection with what I saw. and I really loose my focus. It would be really helpful if you could guide on this.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
I learn through reading the documentation, reading articles about the topic, and watching KZbin videos. Then, I practice everything I think I just learned so I know for sure that I understand it.
@vijithsreevalsam7979
@vijithsreevalsam7979 2 жыл бұрын
@@IAmTimCorey thank you Tim, I m from different backgrounds (electrical eng) and want to have a transition in my career as a developer.. Soon I ll get to that point .. With the help of Tim like personalities.. 👍👍
@KTMFerr
@KTMFerr 5 жыл бұрын
Tim, any idea when I have added all the injection code override function mine OnStartup crashed when I launch the app? It says the ShellViewModel is null. If I comment all the override methods of the dependency injection, it starts working again. Cant find the relation or the root cause. Cheers!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Not sure what is going on.
@pedrotavares41
@pedrotavares41 4 жыл бұрын
Hey Tim, nice tutorials, I am following along and leaving "likes" to them. I just have a question: How would you do if we had two implementations from the same interface?I mean, how the ShellViewModel class would know which to use it? Thanks and keep up with your videos.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
We would need to either differentiate them or we could load multiple views (a list). Ideally, though, you have one for each type.
@toddrothman2765
@toddrothman2765 2 жыл бұрын
this is so funny because you sound just like Louis CK. So I imagine Louie is teaching me how to program :) You have the same sound, pauses, mannerism, etc. so cool.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Interesting.
@toddrothman2765
@toddrothman2765 2 жыл бұрын
@@JohannaMueller57 We can all perceive things differently, the beauty of human nature
@HernanIannella
@HernanIannella 3 жыл бұрын
Hi Tim! How hard is it to replace CaliburnMicro with MVVMCross in an already running application, let's say TRM for instance? Thank you!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I would recommend against it unless you really need to. It will be tricky, but there will be some changes that are more difficult than just a simple replacement.
@craigsunderland3849
@craigsunderland3849 5 жыл бұрын
Hi Tim, I have to thank you for your tutorial sets, they are great. I'm struggling with this video though, to be honest as we progress from video to video, I understand and can follow less and less, ending in simply typing what you type as I have no clue what is happening. Do you have other simpler tutorials for a beginner like myself?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Check out the Tournament Tracker application: kzbin.info/aero/PLLWMQd6PeGY3t63w-8MMIjIyYS7MsFcCi or my Foundation in C# course series: www.iamtimcorey.com/blog/49797/how-to-learn-csharp-well
@dotnetenthousiast1855
@dotnetenthousiast1855 4 жыл бұрын
Hi Tim, When using WPF Core, do you know of any method to integrate the IHTTPClientFactory into this simple container or otherwise use the .NET core Dependency injection alongside Caliburn micro? Keep it up with all your priceless video's ! Grtz
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Stick with this series. We eventually upgrade all of the projects to .NET Core. Then you will see how to integrate simple container with IHTTPClientFactory.
@BochraBouazizi
@BochraBouazizi 4 жыл бұрын
@@IAmTimCorey I really wished you had started this with .NET CORE cause I am actually working a .NET CORE PROJECT. But I am following you and trying to get as much as possible from this. I am currently working with autofac for dependency injection and I don't quite see the difference with Caliburn Micro, can they work together and stuff?
@hellyworld9325
@hellyworld9325 3 жыл бұрын
When I tried to launch it threw an exception 'Object reference not set to an instance of an object'. Then below it says This exception was originally thrown at this call stack: [External Code]. And I get a Break Mode page saying this application is in break mode. Any ideas?
@joseluisadrianom.7771
@joseluisadrianom.7771 3 жыл бұрын
Were you able to get a solution? I got the same error. This is the line throwing the error. DisplayRootViewFor(); Any help is appreciated.
@Frankieboy2008
@Frankieboy2008 3 жыл бұрын
I got similair error and I had typed "viewModel" instead of "ViewModel" in EndsWith("ViewModel")
@joseluisadrianom.7771
@joseluisadrianom.7771 3 жыл бұрын
Thanks @@Frankieboy2008 . I also had typed "WindowManager" instead of "IWindowManager" in the Configure() method.
@thokankit007
@thokankit007 2 жыл бұрын
Thanks 👍
@benedictjohn848
@benedictjohn848 5 жыл бұрын
Hi Tim, how about instantiating Class that is asking for model as argument in its constructor?Is it also excepted for DI? You said in one of your video 'DI with Autofac' that Model is excepted in DI because it only contains data, meaning Model should be instantiated using 'new' statement,correct me if i misunderstood this? Another one is the built-in classes in .net framework can i use DI on all of them or there are some also excepted. Last one, I believe it is possible to use multiple different classes that implement one interface, am i right to register it as-self?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Adding info through the constructor in DI is a bit more advanced. I'll be doing a video on it at some point. As for models not typically being included in DI, that is correct. The use of built-in classes depends on the situation but in general, we add them to DI. Finally, if you have multiple classes that implement one interface, you can register one of them to the interface, apply logic to which one gets returned, return all of them and let the client decide, or you can self-register.
@benedictjohn848
@benedictjohn848 5 жыл бұрын
Thanks Tim.
@minikinuser
@minikinuser 5 жыл бұрын
Hello Tim, I'm so grateful for your tutorials - they are awesome! There's one question I have. Supposing, I want to use another DI container (Castle.Windsor for example). So, the code I have to write to "configure" my WPF App is pretty much the same, isn't it? (It's all about syntax?)
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Correct. You will probably just need to change the setup code and that's it.
@minikinuser
@minikinuser 5 жыл бұрын
@@IAmTimCorey, thanks s lot.
@AkshayKumarTK
@AkshayKumarTK 4 жыл бұрын
Hey Guys, Is there anywhere I can learn about this Dependency Injection System, why we are doing this, how will it help and all?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Here is a video I did on Dependency Injection and how it works (using a slightly different system but the principle is exactly the same): kzbin.info/www/bejne/o3S4f6WIqbuJjbs and here is a video I did on the Dependency Inversion Principle (not Dependency Injection), which is the principle that Dependency Injection is based upon: kzbin.info/www/bejne/hJ-9i4ChrK5pgas
@Sjaik87
@Sjaik87 2 жыл бұрын
For some reason this particular video is not buffering for me? I'm able to watch the episode "WPF with MVVM" before it and "Planning the register" which comes after. But this one will not buffer no matter what i try :O Anyone else with this issue? :)
@emvicladao5999
@emvicladao5999 4 жыл бұрын
Hi Tim! I am passing a connection string in my implementation, thus, have to do something like: _container.PerRequest(); How do we do that?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You would do that in the constructor rather than inside the angle brackets. Otherwise, you are right on track.
@emvicladao5999
@emvicladao5999 4 жыл бұрын
Thank you ^_^
@nixxxization
@nixxxization 5 жыл бұрын
Hello Tim, thank you for your videos and free knowledge, I got stuck @ 26:49 when I write this .PerRequest I get an error that says: The type 'TRMDesktopUI.Calculations' cannot be used as type parameter 'TImplementation' in the generic type or method 'ContainerExtensions.PerRequest(SimpleContainer, string)'. There is no implicit reference conversion from 'TRMDesktopUI.Calculations' to 'TRMDesktopUI.ICalculations'. TRMDesktopUI D:\Demos\TimCoRetailManager\TRMDesktopUI\Bootstraper.cs 29 Active Can you help me ? Thank you in advance.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Does Calculations implement ICalculations?
@nixxxization
@nixxxization 5 жыл бұрын
@@IAmTimCorey Thank you so much, Calculations was implementing ICalculations1 that was a mistake.
@brianhoskins1979
@brianhoskins1979 4 жыл бұрын
At the end you created a simple Calculations class and an interface for it, and then you registered that in your Configure method in the Bootstrapper. What if you have an ICalculations interface and then a bunch of _different_ classes which implement that interface? Do you also generate a new interface for each of the classes which implement ICalculations, and then you register these via their dedicated interfaces in the bootstrapper? And if yes, then by the end of your project you will have a whole bunch of interfaces whose purpose is for nothing more than registering them in the Bootstrapper. This is the intended way to do this? And I guess the same applies to abstract classes? You'd have a new interface for each class which inherits from the abstract base class and you'd register these? Or am I completely misunderstanding what you did?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
It depends on your scenario. Do you anticipate running all of those classes when you want to interact with ICalculation? If so, you can get a list of them back. If you want to have one back, which one? If only one, you put that one in DI. If different ones at different times, you need to have some way of telling the system that. Individual interfaces is an easy option. Another is to have metadata (a bit more advanced). Interfaces are free so use them the way that makes sense for your project. You may have interfaces that are specific to each class. That's ok. Remember that the purpose is to allow us to replace the implementation later, either when we upgrade a class or when we are creating unit tests. Take the ILogger for example. We have more than one implementation, usually. I tend to use Serilog, but Microsoft also has a built-in logger. So, my DI only specifies one logger, even though multiple are available. In my unit tests, I don't want to write log entries when I run tests so I replace the Serilog implementation with an in-memory one.
@argeelearner3978
@argeelearner3978 5 жыл бұрын
I received this error on the ShellViewModel constructor 'ICalculations' is less accessible than method 'ShellViewModel.ShellViewModel(ICalculations)' TRMDesktopUI C:\Users\Rafae\Desktop\C#\TimCoRetailManager\TRMDesktopUI\ViewModels\ShellViewModel.cs Please advise.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are missing the "public" modifier on something (probably ICalculations).
@s-napers
@s-napers 4 жыл бұрын
I know it's been a long time, but in case anyone else has this issue. I found that I was getting the error becasue the interface in ICalculations.cs wasn't public. Changed it to public interface ICalculations and worked
@KarthikNagendiran
@KarthikNagendiran 4 жыл бұрын
Hi Tim, This is a great tutorial for WPF & MVVM. I have got one question for you. How do I keep my Login view out of shell window? I want to load the shell window once the login is succeeded. What changes I need to do ? Please advice.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You would have to use the Window Manager to open a separate window if that is what you really wanted to do. It will be trickier, though, since C# wants to close the application when the Shell View closes. That can only happen if the Shell View opens when the application opens. Why don't you just put the login box inside the Shell View, like I do in this series?
@KarthikNagendiran
@KarthikNagendiran 4 жыл бұрын
@@IAmTimCorey Thanks for your swift reply. Will try that as explained in your series.
@after2003
@after2003 2 жыл бұрын
I would like to utilize built in Microsoft dependency injection in a class library as part of my asp.net mvc application. I know how to inject into controllers and views but I don't know how to instantiate an instance in class library. I would appreciate it if you point me to right direction. Great videos Tim.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Just add those classes to your DI system in your UI project. We are actually doing that with this project. We have a class library and we integrate it into our WPF DI system. We do the same with our API project. I go into a LOT more detail in this course: www.iamtimcorey.com/p/dotnet-core-dependency-injection-in-depth (.NET Core Dependency Injection In Depth).
@jasonmiller1347
@jasonmiller1347 3 жыл бұрын
Gonna have to watch this one twice. I don't really understand what all is going on.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I offer other videos on Dependency Injection, if that might help - kzbin.infosearch?query=injection
@DamianWalczak
@DamianWalczak 5 жыл бұрын
5:40 agree if you are curious or just want to know what particular piece of code does F12 it and find the definition, if nuget is hosted on github go to the source code and try figure it out yourself. Human is the creature of habit and it will gravitate to their preferred nuget packages but before you dive in make sure you undesrstood concepts well. #1.5 speed club
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'm more recommending that you understand the code in your application, not necessarily that you understand how the NuGet package code works, but if your curious, it is nice that you can explore that too.
@groch94
@groch94 5 жыл бұрын
Could you explain what exactly does service mean in programming? To me, I always linked it with windows service. But what does it mean for a software developer?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
It depends on the context but basically it is just a system that does work and sometimes returns values.
@miloskaljevic1127
@miloskaljevic1127 5 жыл бұрын
Tim thank you for sharing your knowledge. I have some issues that i cant resolve. It started with WPF Setup. When i installed Caliburn.Micro, and deleted Main page and changed ShellView as a main page, when i start the app i get message: Cannot find view for TRMDesktopUI.ViewModels.ShellViewModel. after continuing to write code in this video till 20:00 minute,i have tried to start app and i got Message: System.NullReferenceException: 'Object reference not set to an instance of an object.' under DisplayRootViewFor(); Hope that you can help me. Thanks for lessons, you are amazing.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
It sounds like you missed a step somewhere. You might not have added the ShellView or you might be missing a using statement.
@miloskaljevic1127
@miloskaljevic1127 5 жыл бұрын
@@IAmTimCorey i started project again, now works fine. Thanks again :)
@andreworegan7316
@andreworegan7316 5 жыл бұрын
At about 20:00 i tried to start my one but i keep getting an exception of "System.MissingMethodException: 'Cannot create an instance of an interface.'" from the return statement at? protected override object GetInstance(Type service, string key) { return _container.GetInstance(service, key); }
@andreworegan7316
@andreworegan7316 5 жыл бұрын
If i comment out that method the window displays
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'm wondering if this isn't actually your issue. It might be that your issue is where you are requesting an instance of an interface that you did not properly set up in the container. Look at your container configuration and make sure you mapped your classes and instances correctly.
@andreworegan7316
@andreworegan7316 5 жыл бұрын
@@IAmTimCorey Thanks a typo - I had IWindowManager instead of WindowManager in .Singleton() works now thank you
@Jawsh27
@Jawsh27 5 жыл бұрын
Had this issue too. Ended up making the same mistake.
@mirzasisic
@mirzasisic 4 жыл бұрын
Dang, I had the same issue, these comments save me from pulling my hair out - that is if I had any... hahaha
@moihawk666
@moihawk666 4 жыл бұрын
are we going to go over branching and merging?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Probably not in this course, since it is based upon the premise that it is just me doing the work.
@princeruzande2960
@princeruzande2960 5 жыл бұрын
Hi Tim, thank you so much for the brilliant tutorials, but unfortunately, I am getting some errors after deleting Calculations.cs and ICalculations.cs since these two are being used by Bootstrapper.cs. Thanks once again!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Yep, it takes a bit of cleanup. Just follow along with what I did. Once you have them in the class library and once you have referenced the class library in your UI project, you can add the correct using statement in the Bootstrapper file to fix the errors. I did that nearer to the end.
@kinqfabi5573
@kinqfabi5573 Жыл бұрын
My ShellView doesnt Start anymore when i have the GetInstance method in my Bootstrapper. Do you have any idea why this could be?
@IAmTimCorey
@IAmTimCorey Жыл бұрын
My guess is that you upgraded the Caliburn Micro NuGet package to the 4.x version, which has breaking changes. Specifically, there are a few methods that now only have an async version. I believe GetInstance is one of them. Downgrade to the 3.x version and you should be fine.
@kinqfabi5573
@kinqfabi5573 Жыл бұрын
@@IAmTimCorey Thank you very much for that fast Reply! Do you maybe know what the async variation is by hard?
@michaelharmon733
@michaelharmon733 Жыл бұрын
@@IAmTimCorey This seems to be fixed now in 4.0.212
@softwareengineer6558
@softwareengineer6558 5 жыл бұрын
Hello Tim, Thanks for all your great videos, I am enjoying a lot it while learning C#. while typing after you in this video the compiler yale about: Where(type => type.IsClass) giving me an error : Error CS1061 'Type' does not contain a definition for 'Where' and no accessible extension method 'Where' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?) I have the using statement : using System; and even added using System.Reflection; but it still through the error, I reviewed it many times. I can't compile appreciating your help.
@Artavazd.kirakosyan
@Artavazd.kirakosyan 5 жыл бұрын
I did the same mistake too, there should be Types with "S" instead of Type just before Where(type => type.IsClass), or take this full code: GetType().Assembly.GetTypes() .Where(type => type.IsClass) .Where(type => type.Name.EndsWith("ViewModel")) .ToList() .ForEach(viewModelType => _container.RegisterPerRequest( viewModelType, viewModelType.ToString(), viewModelType));
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Lee is correct and yes, watch out for what Artavazd pointed out as well.
@softwareengineer6558
@softwareengineer6558 5 жыл бұрын
@@leeroy1986 i already did that for sure still nothing and i added using system.linq but i figured out my mistake with Artavazd comment , i missed the s :). thanks a lot for replying.
@softwareengineer6558
@softwareengineer6558 5 жыл бұрын
@@Artavazd.kirakosyan Yes this was the mistake i wrote GetType instead of GetType while i take a screenshot from the video to compare it with what i wrote and i missed it too :) Thanks a lot man.
@softwareengineer6558
@softwareengineer6558 5 жыл бұрын
@@IAmTimCorey Got it thanks a lot Tim, keep the great work, I am a fan.
@hillarysagwa5064
@hillarysagwa5064 4 жыл бұрын
hello IAmTimCorey i ve followed this video line by line but iam getting this error mssage whenever i run the application. An exception of type 'System.NullReferenceException' occurred in Caliburn.Micro.Platform.dll but was not handled in user code what could be wrong?
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
It sounds like you probably have a naming issue.
@hillarysagwa5064
@hillarysagwa5064 4 жыл бұрын
@@IAmTimCorey if i comment out this line, it works well protected override object GetInstance(Type service, string key) { return _container.GetInstance(service, key); }
@hillarysagwa5064
@hillarysagwa5064 4 жыл бұрын
@@IAmTimCorey if
@hillarysagwa5064
@hillarysagwa5064 4 жыл бұрын
@IAmTimCorey if i comment out this line, it works well protected override object GetInstance(Type service, string key) { return _container.GetInstance(service, key); }
@davidngo9155
@davidngo9155 4 жыл бұрын
If anyone experience the same issue as commented. Make sure line 31 ###Where(type => type.Name.EndsWith("ViewModel"))### has an upper case V for "ViewModel". Having a lower case v "viewModel" will result in the "System.NullReferenceException" error
@jovandimitrov6604
@jovandimitrov6604 5 жыл бұрын
Nice vids and all but, can you publish some about .Net Core ??
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
The first video in this series laid out the basic roadmap. The plan is to do all .NET Framework at first and then transition the app over to .NET Core. Doing a .NET Core from scratch video is simple (and I'll be doing one that way soon) but it doesn't really simulate where the marketplace is today. New apps may be built in .NET Core but there are a LOT of existing apps that need to be moved over. We are going to tackle this second issue with this course in order to better simulate the real world. That way this channel will have both fresh .NET Core videos and transitioning to .NET Core videos.
@n9434178
@n9434178 5 жыл бұрын
Thanks Tim. The code in Bootstrapper.cs/Configure reminds me a bit of the Factory you created when explaining the dependency inversion principle (kzbin.info/www/bejne/hJ-9i4ChrK5pgas). With respect to the override for the Configure method, does Caliburn Micro create Singletons for the WindowManager and EventAggregator if you do not override the method?
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Yes it does.
@AkshayKumarTK
@AkshayKumarTK 4 жыл бұрын
To be honest, I did not understand everything that was shown in the video. Just following along doing the same things as shown, hoping I will understand them in future. I know what is Dependency Injection in basic. But how and why everything that was done here is too much to grasp in start. A little more on DI would have been nice or a link to a blog post/video to understand it better.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
This video might help: kzbin.info/www/bejne/o3S4f6WIqbuJjbs
@scottrellwi
@scottrellwi 5 жыл бұрын
Thanks for sharing Tim, but you lost me at WPF. I guess I just cant sit through another language that I will throw away after the tutorial. I really need MVC + Web API + SQL Server. I will be back again when you pick up ASP.net MVC again. Thanks again!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I understand that you don't intend to learn WPF, but just to be clear, WPF is just C#. There isn't a different language (except XAML, which is only used to display items on a form, not do any of the actual work). Whether you want to use WPF or not, MVVM is actually just a good use of OOP in C#. Most of what we will do will be in C# classes. The key to remember about C# is that user interfaces are not the language. They are just the visual part of an application. The language is what powers everything, from Console apps through web apps.
@Arrato1977
@Arrato1977 Жыл бұрын
To the certain moment I was intact but then lost completely.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Go back and try it again. Keep at it. Pushing through will be really beneficial for you.
@FrederickGrumieaux
@FrederickGrumieaux 4 жыл бұрын
I have to say, I absolutely do not agree with the statement you make about Singletons. Well at least not in this context, where you are using DI and thus IoC. Here you can perfectly mock singletons when writing Unit Tests. Also; the real problem is storing data in those Singletons, not the fact that you register a class as a singleton. And even that is sometimes okay. Another problem some seem to have with Singletons is to do with muti-threading, but again that is not a problem of singletons, but a problem with the implementation of you class. After all even a transient instance could be called from multiple threads at the same time. In fact a class can never tell if it will be called concurrently.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You just went through a list of reasons not to use a singleton (or at least to be very cautious about it). That was what I was trying to communicate. Err on the side of instantiation.
@mdabuzar2130
@mdabuzar2130 5 жыл бұрын
Sir, please entityframe core video
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@sachdevalamin3174
@sachdevalamin3174 Жыл бұрын
Caliburn.Micro 4.0 (untested code fix): protected override async void OnStartup(object sender, StartupEventArgs e) { await DisplayRootViewForAsync(); //DisplayRootViewFor(); }
Planning the Register - A TimCo Retail Manager Video
42:44
IAmTimCorey
Рет қаралды 34 М.
WPF Login Form Creation - A TimCo Retail Manager Video
1:04:38
IAmTimCorey
Рет қаралды 72 М.
Pleased the disabled person! #shorts
00:43
Dimon Markov
Рет қаралды 31 МЛН
Sigma girl and soap bubbles by Secret Vlog
00:37
Secret Vlog
Рет қаралды 15 МЛН
EVOLUTION OF ICE CREAM 😱 #shorts
00:11
Savage Vlogs
Рет қаралды 11 МЛН
Dependency Injection, Generic Host, and WPF
2:44:29
Kevin Bost
Рет қаралды 7 М.
C# Dependency Injection with Autofac
54:45
IAmTimCorey
Рет қаралды 294 М.
MVVM + Dependency Injection in Swift | Unit Testing | iOS
29:29
Getting User Data - A TimCo Retail Manager Video
1:13:38
IAmTimCorey
Рет қаралды 43 М.
What is Dependency Injection?
6:48
Scott Bailey
Рет қаралды 114 М.