Win forms designer not opening a derived form in .NET 6. The Extender Provider failed to return an Extender for this object - winforms

Deleting bin and obj folders, cleaning solution, and restarting studio did not help.
Designer does open a base form.
Inherited form (FrmBase) has an empty constructor and no parameters. Some of the derived forms have and some do not have an empty constructor, constructor with or without parameters, the error is the same for all.
FrmBase is in another project.
Update 2022-08-05: when I copy the exact form file with its designer, change the name of the class and it works. 😐 But I don't want to do that for a hundred+ forms in my solution. I also looked at differences in the project file for those forms and there is none.
The Extender Provider failed to return an Extender for this object.
Instances of this error (1)
Hide Call Stack
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.InvisibleEditor..ctor(IServiceProvider serviceProvider, String filePath, IVsHierarchy hierarchy, Boolean needsSave, Boolean needsUndoDisabled)
at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.TextManagerAdapter.CreateTextPoint(FileCodeModel fileCodeModel, VirtualTreePoint point)
at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements.AbstractCodeElement.get_StartPoint()
at EnvDTE.CodeClass.get_StartPoint()
at Microsoft.DotNet.DesignTools.Client.CodeDom.VsCodeDomProvider.Parser.ProcessClass(CodeClass vsClass, CodeNamespace namespace)
at Microsoft.DotNet.DesignTools.Client.CodeDom.VsCodeDomProvider.Parser.ProcessNamespace(CodeNamespace vsNamespace, CodeCompileUnit compileUnit)
at Microsoft.DotNet.DesignTools.Client.CodeDom.VsCodeDomProvider.Parser.ProcessFileCodeModel(FileCodeModel fileCodeModel, CodeCompileUnit compileUnit)
at Microsoft.DotNet.DesignTools.Client.CodeDom.VsCodeDomProvider.Parser.Parse(TextReader codeStream)
at Microsoft.DotNet.DesignTools.Client.CodeDom.MergedCodeDomProvider.Parser.System.CodeDom.Compiler.ICodeParser.Parse(TextReader stream)
at Microsoft.DotNet.DesignTools.Client.CodeDom.CodeDomSource.get_CompileUnit()
at Microsoft.DotNet.DesignTools.Client.CodeDom.CodeDomManager.GetDeclarations()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.PerformServerLoad()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.DeferredLoadHandler.PerformLoad()
Help with this error
Could not find an associated help topic for this error. Check Windows Forms Design-Time error list
Forum posts about this error
Search the MSDN Forums for posts related to this error

The problem was that I have another .NET Framework project that has those forms linked from .NET6 project. When I just copy the form to .NET Framework project, the problem is resolved.

Related

How can I deploy the .dna file from ExcelDna?

I am trying to create an Excel (2007) Add-in that will respond to PivotTable changes, using this code:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Excel.Worksheet sh = this.Application.ActiveSheet;
sh.PivotTableUpdate += new
Excel.DocEvents_PivotTableUpdateEventHandler(sh_PivotTableUpdate);
}
void sh_PivotTableUpdate(Excel.PivotTable TargetPivotTable)
{
MessageBox.Show("sh_PivotTableUpdate event fired");
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
Once the .dll was created, deploying it/generating an .xll file became a challenge; I used this post for guidance there, and do now have an .xll file.
I was able to add this to the Excel spreadsheet (.xlsx file) that I want to respond to the code (via File > Excel Options > Add-Ins > Go... > Browse), but get this err msg on adding the .xll file:
I did see that there is a *.dna file here \packages\ExcelDna.AddIn.0.33.9\content\ExcelDna-Template.dna
...but making a copy of that file and changing the name of it to [projectName].dna (Excel2010AddInForRptRunner-AddIn.dna), and then copying it to the same location as the .xll file with the .xlsx file is not the solution (no pun intended). Changing the PivotTable manually does not fire the event/I see no "sh_PivotTableUpdate event fired" message.
The .dna file does reference the .dll like so:
<ExternalLibrary Path="Excel2010AddInForRptRunner.dll" LoadFromBytes="true" Pack="true" />
So what do I need to do to resolve the err msg I get and get the .xll file to be accepted by the spreadsheet so that its code will run and the PivotTableUpdate event handler is fired?
There are two issues that I see in your snippet:
The first is that you seem to have mixed the VSTO Office stuff with Excel-DNA (I see this from the ThisAddIn_... code, which relates to VSTO). These don't mix at all - you can't use Excel-DNA inside a VSTO add-in project. Any namespaces that start with Microsoft.Office.Tools... indicate there is a problem. This might happen is you start with an "Office Add-In" or "Excel Add-in" as your project type.
There is a also mess in your project related to the NuGet packages - somehow the output files are inside the package directory, or the package directory has been overwritten or changed somehow. You should not have to ever edit anything under packages\...
If everything is correct, then the files you are interested in will be found in bin\Debug and bin\Release under your project directory. Usually you can redistribute only the single ...-AddIn-packed.xll file (which you can also rename if you want to).
I suggest you make a new "Class Library" project (not an Office add-in or anything like that) and install the ExcelDna.AddIn package again. Then follow the instructions in the ReadMe file that pops up to make a simple add-in with a single UDF function, and check that this runs and can be debugged and deployed correctly.
After you have that working perfectly, you can incorporate access the COM object model into your add-in by following these two steps:
Add a reference to the Excel Interop assemblies (Microsoft.Office.Interop.Excel and Office), either directly via "Add Reference", or by installing the ExcelDna.Interop assembly from NuGet.
Get hold of the right Application root object by calling ExcelDnaUtil.Application. The object returned can be cast to a Microsoft.Office.Interop.Excel.Application and used to get to the whole COM object model from there, and hook up your event handlers etc.

Recomposition issue with a Modular Silverlight application

I'm working with a Silverlight 4 application and we use Prism/MEF to build modules.
Each module is created as a Silverlight application. We then use a ModulesCatalog.xaml file to control how the modules are loaded.
We had 6 modules and everything was working perfect.
This week we're adding a 7th module and we just have the new Silverlight application created. We setup the module class as follows.
[ModuleExport(typeof(InsightModule))]
public class InsightModule : IModule
{
}
Then we added an entry to our ModulesCatalog file.
Now when we run the application we start getting all types of recomposition errors. The stack shows this.
at System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.OnExportsChanging(ExportsChangeEventArgs e)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.OnCatalogChanging(Object sender, ComposablePartCatalogChangeEventArgs e)
at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.OnChanging(Object sender, ComposablePartCatalogChangeEventArgs e)
at System.ComponentModel.Composition.Hosting.AggregateCatalog.OnChanging(ComposablePartCatalogChangeEventArgs e)
at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.RaiseChangingEvent(Lazy`1 addedDefinitions, Lazy`1 removedDefinitions, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.Add(ComposablePartCatalog item)
at Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleInitializer.CreateModule(ModuleInfo moduleInfo)
at Microsoft.Practices.Prism.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo)
Then you get the standard output.
The exception message was: The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced multiple composition errors, with 57 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.
1) Change in exports prevented by non-recomposable import 'EyeCue.Common.AboutEyeCueView.ViewModel (ContractName="EyeCue.Common.AboutEyeCueVM")' on part 'EyeCue.Common.AboutEyeCueView'.
WHat's puzzling is why none of the other 6 modules caused this problem but now all of a sudden, this new module without anything going on in it is causing a recomposition of the catalogue. It makes no sense.
Plus I have ctor's that import in some cases and that's they what I had to do to get things to work, so this is not as simple as going to setting the Allow Recomposition attribut.
I've downloaded the VisualMFX but this line of code throws an Object Not initialized exception.
this.compositionInfo = new CompositionInfo(_aggregateCatalog, _container);
Both _aggregateCatalog & _container are not null when this happens.
In summary, why would a 7th module all of a sudden start causing recomposition? Especially when the module isn't even defining any exports or imports at this time? That leads to how do we stop it to address this problem?
The issue turned out to be a reference to an assembly which had Copy Local set to true.
Making sure all references which are also set in the main application assembly were set to Copy Local = false seems to resolved the problem.

System.TypeLoadException was unhandled / Inheritance security rules violated while overriding member

Can you create a .NET 4 version of your app for testing was the bosses' innocent question - sure!
But after I changed our 27 projects in our Winforms application to .NET 4, and recompiled, when launching the app, I get
System.TypeLoadException was unhandled
Message=Inheritance security rules violated while overriding member:
'MyCustomORM.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'.
Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Hmmm.....
MyCustomORM does indeed implement the ISerializable interface and thus has this method
[Serializable]
public abstract class MyCustomORM: IMyCustomORM, ISerializable, ICloneable, ISecurable
{
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
// do stuff here.......
}
}
and I also have two classes that derive from Exception that override the GetObjectData method.
But what could be wrong here?? Googling around I found some additional attributes to stick onto my method and namespace - so I did:
[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)]
namespace MyApplication.ORM
{
[Serializable]
public abstract class MyCustomORM: IMyCustomORM, ISerializable, ICloneable, ISecurable
{
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
// do stuff here.......
}
}
}
but that doesn't change anything.....
The exception happens even before my first line of code in my static Main() method is reached....
I've combed through the project and removed any references to old .NET 1.1 libraries (yes, the app is that old.....) and replaced them with their .NET 4 counterparts (mostly log4net). Still no luck....
Any ideas??
Is the assembly in which the MyCustomORM class resides marked with SecurityTransparentAttribute? If so, the problem stems from changes in the security transparency model between .NET 3.5 and .NET 4.0. For your testing scenario, you may wish to simply opt into using the older transparency mechanism. To do so, add the following assembly-level attribute:
[assembly: SecurityRules(SecurityRuleSet.Level1)]
For more information on the differences between the Level1 and Level2 transparency models, see http://blogs.msdn.com/b/shawnfa/archive/2009/11/12/differences-between-the-security-rule-sets.aspx.
I know this is pretty old, but I ran into this issue with one of my assemblies recently. It only occurred on some machines and was very difficult to determine what was causing it. I didn't just want to put security rule adjustments in, so after much searching I ran across the SecAnnotate tool that is included with Visual Studio.
Using SecAnnotate to Identify Transparency Violations
Using the tool I was able to determine that one of my assemblies was referencing an older version of a dll which contained some security attributes which were causing the problem. Updating the reference fixed the issue.
The SecAnnotate tool seems like a great way to identify any violations that you may have accidentally overlooked or didn't know about.
Hope this helps someone.

WPF unit test DirectoryNotFoundException

I am having trouble instantiating a view model wich loads an image from Resources.
The line that fails in the assembly I'm testing is:
get { return new ImageSourceConverter().ConvertFromString("pack://application:,,,/Resources/Icons/Commands/DisabledNewSessionIcon.png") as ImageSource; }
the exception is:
Unable to create instance of class
GPAnalysisSuite.Tests.View_Models.Session_Controller.SessionControllerViewModel_NonDefaultConstructorTester.
Error:
System.IO.DirectoryNotFoundException:
Could not find a part of the path
'C:\TGP\GP Analysis
Suite\Application\Tests\TestResults\Paul_PAUL-GP
2011-03-17
11_27_28\Out\Resources\Icons\Commands\DisabledNewSessionIcon.png'..
I have already found a solution to a simular problem and included the following to the TestClass:
[AssemblyInitialize]
public static void InitialisePackageUriHelper(TestContext context)
{
PackUriHelper.Create(new Uri("reliable://0"));
new FrameworkElement();
System.Windows.Application.ResourceAssembly = typeof(App).Assembly;
}
I can see that I need to preserve the Uri of the assembly I'm testing but have no idea how to do it, can anyone help?
I appear to have solved the problem by changing the resource build action from Content to Resource.
Although I have to rebuild the solution everytime I want to run the unit tests this is now workable at least.

How to build multilingual Crystal reports

We are developing a multilingual Winforms application using visual studio 2008. I am trying to figure out how I can create multilingual reports using crystal Reports.
Is there any thing similar to .net resource files in the Crystal reports world?
I'm sorry that I'm robbing you of your tumbleweed badge, but I don't think Crystal has the multiple language support similar to .NET. I think that your only option is to have a separate report for each language and pass the data into the report in the language that you wish to display.
Here is a link of a similar answer.
http://www.dbforums.com/crystal-reports/991737-crystal-report-multillingual-support.html
This would be a manual way of doing this:
Create a report for each language you want and put into the proper folders structure. i.e. all japanese reports will go into rpt_ja/ folder.
Use .Net Resource file to specify report resource name and full resource name for each language:
resource.resx
RPT_SAMPLE -> report01.rpt
RPT_SAMPLE_FULL -> MyCompany.NameSpace.Reports.Report01.rpt
resource.ja.resx
RPT_SAMPLE -> rpt_ja\report01.ja.rpt
RPT_SAMPLE_FULL -> MyCompany.NameSpace.Reports.Report01.ja.rpt
Then use this value in the report code file: Open the report .cs file and change:
public override string ResourceName {
get {
// Change this to HttpContext.GetGlobalResourceObject("Resource", "RPT_SAMPLE").ToString();
return "report01.rpt";
}
set {
// Do nothing
}
}
public override string FullResourceName {
get {
// Change this to HttpContext.GetGlobalResourceObject("Resource", "RPT_SAMPLE_FULL").ToString();
return "rpt_ja\report01.ja.rpt";
}
set {
// Do nothing
}
}
EDIT: HttpContext is for ASP.Net web application. In winform, you can try Properties.Resources.ResourceManager.GetString() to get the string from resources
A client ask me for a solution to this issue. I developed a solution based on Crystal Reports contentLocale keyword and Custom Functions. See my posting: http://www.cogniza.com/blog/?p=55.

Resources