ServiceLocator Current GetInstance? - service-locator

I have assemblies discovered in a directory using MEF and they are loaded when needed during runtime when a user selects a menu.
After a assembly is loaded each has its own UI and views can be added to it as the user needs them, but when I use excelView = ServiceLocator.Current.GetInstance(); I get an exception.
Exception Details
How do I solved this problem, because I'm assuming directory discovered assembles are added to the AggregateCatalog so the ServiceLocator can find them right?
This is how the main IExcelView is setup:

I found the problem, I needed to add the Key I used to Export the class.

Related

Xcode 11 doesn't recognize Core data Entity

I just declared an entity called "Users" array:
var UsersArray = [Users]()
I got this error:
use of unresolved identifiers "Users"
hint : I did import CoreData and created the entity
Please try this solutions !!
Solution 1 :-
Product->Build for testing solved this issue for me(it solves most unresolved identifier bugs for some strange reason)
Solution 2 :-
changing import Foundation to import UIKit.
It seems like UIApplication isn't included in Foundation framework.
Solution 3 :- Highlight the Data Model, go to Editor -> Create NSManagedObject Subclass...
Solution 4 :-
Create the NSManagedObject files and then delete them and everything is fixed.
Hope this helps thank you.
If your entity is actually created, just close and re-open XCode. This works for me everytime. The other solutions, such as clean build, build etc, didn't work for me.
Just ran into this issue after renaming an entity and figured I should post here how I resolved it.
Typically after making changes in the data model and getting compilation errors, I just do Product > Clean Build Folder, then Product > Build and that should take care of the errors.
However, the steps above didn't help this time. After scratching my head for while, I found the culprit with following steps:
In the Project navigator, select your .xcdatamodelId file
In the Configurations section, select the appropriate configuration
Look for the entity in question and make sure the class name is correct (in my case, the entity and the class were not the same)
Other possible solutions:
(A) Re-launch Xcode
This is the solution that worked for me. (See this answer)
(B) Check if you did not forget to finalize your entity description
Typically: forgot to assign a type to one of the attributes (still "undefined").
(C) Clear derived data
Reason: The generated core data managed objects subclasses's source code files are in the project’s derived data location.
Note: you might have to re-link your swift packages is using SPM.
I also had to deal with this issue even working with the latest Xcode12.3 on a SwiftUI project where I didn't checked the CoreData option at project creation.
After adding a class to instantiate the NSPersistentContainer, loading the stores, creating model.xcdatamodel file with an entity and a text field plus a button on a view, then it shows an error saying: "cannot find Item in scope".
It's a bit difficult to write code when you expect the entity to help out with autocomplete. First, I thought I forgot to initialize my class or missed a bracket, but it wasn't that either.
I tried cleaning up, rebuilding and running the project several times with build failed as result. I had to close this particular project then all errors got dismissed. No needed to restart Xcode.
I faced the same issue. Doesn't included Coredata on the beginning of the project. Later added necessary files and core data stack. But when trying to fetch the data from the Entity name and the Xcode throwing the same error.
Later, I closed the project and again opened on Xcode and it started to work.
I had this issue with an .xcdatamodel that I had created in another project and moved it into this one.
I solved it by selecting the .xcdatamodel file, turned of the "File Inspector" and then under "Target Membership", I made sure that all the targets were selected.
for me the entity name and class name was different, and I was refering to entity name for Data Type

MSComctlLib reference/components load with "was not a loaded control class" error

I'm having trouble oppening an project developed in VB6. Some controls attached with MSComctLib class are not loading.
I'm using Windows 7.
In the error analysis the following message appears (without the number of lines):
Class MSComctlLib.ImageList of control ImageList1 was not a loaded control class.
Class MSComctlLib.Toolbar of control Toolbar1 was not a loaded control class.
MSComctlLib.StatusBar class of control sbStatusBar was not a loaded control class.
and then a lot of invalid property names,
Ex:
The property name _ExtentX in ImageList1 is invalid
The property name Buttons in Toolbar1 is invalid
...
According to the guidance of microsoft support site http://support.microsoft.com/kb/896559, an update would be the solution http://www.microsoft.com/en-us/download/details.aspx?id=10019
I tried running the executable VisualBasic6-KB896559-v1-ENU
but I still have the same error when opening the project.
Could someone tell me how to solve it?
Thanks in advance!
If you don't have the common controls selected in your project, but the controls are on a form, then you'll receive these errors when you try to load the project (or add a pre-existing form to a project that doesn't have the component selected).
On the VB6 menu, select Project-Components. Scroll down to Microsoft Windows Common Controls 6.0 (if you have a service pack installed, then the SP level will usually be at the end of the library name). Select that component, click Ok. Save the project, and then reload the project.
If this is the source of your issue, you should now be able to load those forms that have a reference into the common controls.

ATG browser components is not available

I want to create new companent in ATG. And if I forward to Browser Companent page, then I have 404 error. How I can fix this?
I assume that you have created a new component by creating a .properties file. The things to look for are
Is the file in an appropriate config layer? i.e. is it in a location on the configpath, such as the config directory of a module, or the localconfig directory of a server, where the application expects to look for .properties files?
Is the file a valid .properties file and properly formatted?
Is the class mentioned in the $class property correct, valid and fully qualified (package name and class name)
Has the named class been compiled successfully?
Is the named class available on the classpath? i.e. is it in the classes.jar of a module or in the classes directory (if that is how the module's class path has been defined?
Is the class a valid JavaBean - particularly, does it have a no-argument constructor?
Have you compiled, built and assembled your ATG application since creating this new component?
Have you restarted your ATG application since creating this new component?
Assuming this is all correct and yet you still cannot see your component, the next step is to troubleshoot why it is not visible.
Is the path to your component you are using in the dyn/admin component browser correct?
If the path is correct, and you still see an error in the browser, then take a look at the server logs (for around the time you first tried to access the component) - you might see an error or a sequence of errors telling you why the server could not instantiate the component
Can you go to the containing folder and see if the component is listed there - though it is OK if you cannot because it may not have been started if nothing is referencing it
Can you see your component in the ACC. Start the ACC, and go to View Components by Path and navigate to were you think your component should be. Can you see it there? If so, it means that your properties file is OK.
In the ACC, When you click on the puzzle-piece icon that represents your component, does it show it as being an instance of your class or as an instance of Object. If Object, it means that it cannot determine the class of the component
In the ACC, double-click the component and try to start it. Keep looking at the server logs as you do so
This should help you get to the bottom of things.

How to make Modules use Application View Helpers?

Since, adding some extra modules to the zend framework application, a lot of errors are popping out. By default, all the extra modules tend to use the same layout file to render a html, but for view helpes, it searches it's own folder.
In my case, I made a view helper, to load some template's css file. I named it LoadTemplate and placed it inside APPLICATION_PATH."/view/helpers"
It works perfectly, until I browse to a module. Then it gives a error saying
Plugin by name 'LoadTemplate' was not found in the registry; used paths: Custom_View_Helper_: x/x/application/modules/custom/views\helpers/ Zend_View_Helper_: Zend/View/Helper/
It is searching in the wrong folder.
Can't we tell it to search its folder first, and if not found go and find the helper from the default or Application's View Helper?
If your helper is in that directory, make sure it is called Zend_View_Helper_LoadTemplate, the function is called loadTemplate and the file name is LoadTemplate.php
Edit -
Also check out this blog post by Rob Allen: http://akrabat.com/zend-framework/view-helpers-in-modules/

FacebookSDK - AllowPartiallyTrustedCallers Problem

I'm using the latest version of the FacebookSDK (4.0.2) (facebooksdk.codeplex.com)
And I noticed the Src code is made up of several projects namely:
1)
Samples -> Facebook.Samples.AspWebsite Project
Samples -> Facebook.Samples.MvcFacebookApp Project
Samples -> Facebook.Samples.MvcWebsite Project
2)
Tests -> Facebook.Tests
Tests -> Facebook.Web.Tests
3)
Facebook Project
Facebook.Web Project
Facebook.Web.Mvc Project
Okay, so I am building a Facebook Canvas .Net 4.0 MVC 2 application and am simply using the Facebook.Samples.MvcFacebookApp Project and replacing and adding classes and files as I see fit for my situation. However I have come to the point where my site will be running on a Microsoft Azure cloud and I want to abstract the data layer (database) into it's Project. So I went ahead and created a new Project in the solution called BusinessData and added an EntityDataModel to it, so now the solution looks like this:
1)
Samples -> Facebook.Samples ...
2)
Tests -> Facebook.Tests ...
3)
Facebook Project
Facebook.Web Project
Facebook.Web.Mvc Project
BusinessData Project
-> Business.edmx
Great so now I add a reference to the BusinessData Project to my Facebook.Samples.MvcFacebookApp Project and try and access my database. However I get this error in my TrackUserAttribute.cs class in the Facebook.Samples.MvcFacebookApp Project:
System.MethodAccessException occurred
Message=Attempt by security transparent method 'Facebook.Samples.MvcFacebookApp.Models.TrackUserAttribute..ctor()' to access security critical method 'BusinessData.BusinessEntities..ctor()' failed.
Assembly 'Facebook.Samples.MvcFacebookApp, Version=4.0.2.0, Culture=neutral, PublicKeyToken=null' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.
Source=Facebook.Samples.MvcFacebookApp
StackTrace:
at Facebook.Samples.MvcFacebookApp.Models.TrackUserAttribute..ctor() in C:\Users\rkara\Desktop\FacebookPazooza\ThuziFacebookSDK\Source\Src\Facebook.Samples.MvcFacebookApp\Models\TrackUserAttribute.cs:line 13
InnerException:
After some uneventful research and not being fully understood about CAS Policy and how that has evolved with ASP.Net 4.0 my understanding is that the GlobalAssemblyInfo.cs file contained within all of the projects of the FacebookSDK solution has something to do with it.
This line of code in the GlobalAssemblyInfo.cs file:
#if !(SILVERLIGHT || TESTS)
[assembly: AllowPartiallyTrustedCallers]
#endif
seems to be the culprit. According to this Microsoft expert:
http://www.simple-talk.com/dotnet/.net-framework/whats-new-in-code-access-security-in-.net-framework-4.0---part-i/
BusinessData has SecurityCritical level privileges. My class TrackUserAttribute.cs only has SecurityTransparent, so therefore cannot does not have privileges to invoke methods in the BusinessData assembly. Is this correct?
I've tried all sorts of things to get this thing to work even removing [assembly: AllowPartiallyTrustedCallers] from the GlobalAssemblyInfo.cs file, but I get another problem with the .edmx file itself saying it can't load the metadata, so I assume it still has something to do with full trust privileges etc.
I am sure there is a simple answer to this and am sure the guys who developed this SDK wrapper would have consider the fact that people will be extending their SDK to suit individual needs.
What is the best approach for me to ensure abstraction of my data and anything else I want to abstract without having to tie it into the projects provided?
For now and to continue with development and not be tied up in this for too long I've just stored my entity model (edmx) into the models folder of the Facebook.Samples.MvcFacebookApp. This works for now but I would much rather store the edmx in its own project.
Cheers
Rob
Ok so after I left that problem and moved onto installing log4net as a event logger for my application I came across this site:
http://it.toolbox.com/blogs/daniel-at-work/using-log4net-in-cnet-26794
Essentially I wanted to convert log4net to asp.net 4.0 rather than 1.0/2.0 that it was originally written in. Then after reading through this guys instructions on how he got the old log4net code to work in 4.0 the aha! moment came. Essentially all he needed to do was to put this attribute into his AssemblyInfo.cs file:
[assembly: AllowPartiallyTrustedCallers]
So I did the same for my BusinessData project and updated the AssemblyInfo.cs file there, and hey presto it worked!
After some deep contemplation I figured that what this did was allow my Facebook.Samples.MvcFacebookApp partial privileges to call a SecurityCritical assembly including those objects contained within it. Thus I could go ahead now and call my edmx (EntityDataModel) in this assembly from the Mvc application.
The second fix and is not fully known why this is necessary but it fixes the problem is to copy the connection string from the App.config file to the Web.config file in the Mvc application. For some reason the edmx seemed to try to read from the web.config instead of the App.config for the connection string. So now I have the same connection string in the App.config and Web.config file.
Meh! it works and I'm happy ... moving on!
:-D