tag:blogger.com,1999:blog-5295746446529817470.post5405077393307132223..comments2023-05-09T16:29:24.130+02:00Comments on Dotnet by Example: A very basic MEF sample using ImportManyJoost van Schaikhttp://www.blogger.com/profile/02182444268071162776noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-5295746446529817470.post-78472054698937882172020-06-26T23:32:02.565+02:002020-06-26T23:32:02.565+02:00Thank you sir :) Did the job 👍Thank you sir :) Did the job 👍Anonymoushttps://www.blogger.com/profile/05950491613454938481noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-16975149203530879212014-06-18T08:35:53.882+02:002014-06-18T08:35:53.882+02:00Thanks for the example. I use it as starting point...Thanks for the example. I use it as starting point for plugin.Anonymoushttps://www.blogger.com/profile/00420137381178633140noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-80779050839181245892013-05-14T01:53:52.921+02:002013-05-14T01:53:52.921+02:00Using ReSharper with shadow DLL's feature turn...Using ReSharper with shadow DLL's feature turned on breaks the unit tests. It is due to the Path.GetExecutingAssembly(). If you change the Importer code to use the AppDomain.BaseDirectory construct, then this is fool-proof... :-)<br /><br />Thanx for you post and example code. It was golden for me!Chiphttps://www.blogger.com/profile/14449671956321117869noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-6863962066333941312012-08-14T10:13:26.150+02:002012-08-14T10:13:26.150+02:00@Şafak I love to see a problem solve itself ;-) Th...@Şafak I love to see a problem solve itself ;-) Thanks for coming back and sharing!Joost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-36034194938256047922012-08-13T13:45:20.493+02:002012-08-13T13:45:20.493+02:00Oops, sorry, I got it working. I just removed the ...Oops, sorry, I got it working. I just removed the "Path.GetDirectoryName" part, guess it was getting me the parent or so, anyway, thanks again for the great example.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-24506154426363741132012-08-13T12:23:15.636+02:002012-08-13T12:23:15.636+02:00Yes, I actually used your sample directly. The onl...Yes, I actually used your sample directly. The only thing I tried to change was the folder. I even tried:<br />catalog.Catalogs.Add(new DirectoryCatalog("C:"));<br />MEF checks the application path instead of C:\ for DLLs.<br />The weird part is that it checks the directory (it throws an exception if there is no directory at the specified path) but as long as a directory that exists is specified, it doesn't use it.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-83566822321094291322012-08-08T11:42:52.649+02:002012-08-08T11:42:52.649+02:00@Şafak I am afraid I don't know. Have you chec...@Şafak I am afraid I don't know. Have you checked the actual paths both my and your sample code are trying to query and compare them?Joost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-68506492013620304462012-08-03T16:53:34.241+02:002012-08-03T16:53:34.241+02:00Hi there, this is a great example though I couldn&...Hi there, this is a great example though I couldn't manage to change the directory that MEF checks. I tried this:<br /><br />var appPath = Assembly.GetExecutingAssembly().Location;<br />var subDir = Path.Combine(appPath, "plugins");<br />catalog.Catalogs.Add(new DirectoryCatalog(subdir));<br /><br />But it still checks the application's directory and no sub-directories, especially not the plugins folder. How can I make it to look there? :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-49950163470372297032012-07-10T08:43:38.063+02:002012-07-10T08:43:38.063+02:00Thanks a ton!!!
really good example for concept.
...Thanks a ton!!! <br />really good example for concept.<br /><br />Good starting point to explore MEFMahesh Malpanihttps://www.blogger.com/profile/09932308622478356990noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-43895653616528063692012-05-01T10:56:04.127+02:002012-05-01T10:56:04.127+02:00@David: apparently generic contracts are not suppo...@David: apparently generic contracts are not supported out of the box. Never tried that, too. Does this link help? http://www.codeproject.com/Articles/323919/MEF-GenericsJoost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-51341186623105486662012-04-27T14:17:19.275+02:002012-04-27T14:17:19.275+02:00Hi,
I'm already googling for a day without fi...Hi, <br />I'm already googling for a day without finding a solution. In my case, my contract is generic. So my interface has a Type parameter, that limited to class.<br /><br />So I tried:<br />1. ImportMany with no type parameter<br />2. ImportMany with object as type parameter<br />3. ImportMany with the same type I exported my concret implementation.<br /><br />Only the last one works. As far as I don't know what "Extension" might be implemented in future, I don't be able to specify a type for importing. <br /><br />Is there something I missed?<br /><br />Thanks in anticipation<br /><br />DavidDavidhttps://www.blogger.com/profile/04137726294390330044noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-46956069322988709322011-11-19T11:49:21.231+01:002011-11-19T11:49:21.231+01:00@Thomas6767 You are right of course. I just wanted...@Thomas6767 You are right of course. I just wanted to keep things simple for the beginner.Joost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-30001278672559319682011-11-19T11:48:46.677+01:002011-11-19T11:48:46.677+01:00@joelrondeau I ignore them or put pragmas around t...@joelrondeau I ignore them or put pragmas around them ;-)Joost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-64181411761277316822011-11-12T17:54:36.598+01:002011-11-12T17:54:36.598+01:00Really one of the best examples for beginners.
But...Really one of the best examples for beginners.<br />But there is a problem with the last part. The test project should NOT reference the exportingLib, that's the whole point of MEF. You have to use the post-build event in the exportingLib to get it into the assebly: copy "$(TargetPath)" "$(SolutionDir)\bin\$(ConfigurationName)"Thomas6767https://www.blogger.com/profile/14376639392206482115noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-20755779997862367422011-11-11T15:29:47.939+01:002011-11-11T15:29:47.939+01:00What do you do about the CS0649 warning on operati...What do you do about the CS0649 warning on operations? ('operations' is never assigned to, and will always have its default value null)?joelrondeauhttps://www.blogger.com/profile/09176415061849112731noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-33739154421673285552011-08-30T18:01:36.983+02:002011-08-30T18:01:36.983+02:00To the point!!!To the point!!!Jinson Geohttps://www.blogger.com/profile/16707151603527765222noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-62591524026874490962011-08-03T17:49:00.977+02:002011-08-03T17:49:00.977+02:00Came across this while trying to understand MEF - ...Came across this while trying to understand MEF - really nice article and explanation! Thanks :)The IT Kidhttps://www.blogger.com/profile/01081305093227611342noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-54917937576337477912011-06-07T08:28:12.193+02:002011-06-07T08:28:12.193+02:00@HARSHA I use nUnit for unit tests. Please donwnlo...@HARSHA I use nUnit for unit tests. Please donwnload that, reference to nunit.framework.dll and you problem should be solved.Joost van Schaikhttps://www.blogger.com/profile/02182444268071162776noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-69153307199793364672011-06-07T07:33:54.811+02:002011-06-07T07:33:54.811+02:00Hi,
I am facing problem in the last part of the co...Hi,<br />I am facing problem in the last part of the code.<br />Creating ImportingLib.Test.Which class name should be there in this project.Should the class inherit from other class.I have added all the required references.It gives me error on [TestMethod].<br />The Type or namespace Testmethod could not be found. You are missing a directive or assembly.<br /><br />Kindly help me asapHARSHAhttps://www.blogger.com/profile/05819055776477658381noreply@blogger.comtag:blogger.com,1999:blog-5295746446529817470.post-51682632611495258712010-10-14T11:13:36.097+02:002010-10-14T11:13:36.097+02:00Hi Joost,
Thanks a lot for the beautiful example ...Hi Joost,<br /><br />Thanks a lot for the beautiful example of using MEF - really the best example I have found around.<br /><br />You saved my day :-)<br /><br />Best regards AndersAndershttps://www.blogger.com/profile/05637227036820483574noreply@blogger.com