Again "A Web Part or Web Form control on this Page cannot be displayed or imported. " in editorPart project - vb.net

I have a question concerning safe controls in Sharepoint development. I went through several proposed solutions for this problem but neither of them were able to fix the issue. What I basically did was to translate a C# project into VB one using Visual Studio 2010.
This project creates a Visual Web Part in Sharepoint and overrides a set of procedures/functions so you can get a dropdown list populated with SPP lists in the web editor part custom properties. The new VB projects seems free of bugs or translation errors because when I build the project I don't receive any warning/error. The solution deployment is correct, but when I try to use my web part in an empty spp page I receive the infamous message "A Web Part or Web Form control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe".
What I double-checked is the project visual web part "safe control entries" collection that contains the (supposed) correct entry with a valid Strong Name
I did several modification to this part of project; i.e., in the IIS web.config there is still an entry as <safecontrols> containing the same information found in "Safe control entries". I even created another empty project leaving all default names trying to avoid this kind of problem when you rename the Visual Web Part name but still with no luck.
Update
Hi #Tome. If I can, I'll be more than happy to attach the source project.
#Adi, I cannot debug the application because my local Sharepoint refuse to use the web part because of the unsafe control.
For the chronicle, my SPP 2010 runs on top of a W2008 server in a virtual machine and I trust it works because this is not the first project I wrote. As I said I'm quite new in SPP developing but I know how to find the information I need in order to go over the issues I encounter while programming in a new environment (not this time, it seems).
The original C# project runs flawlessy but, evidently, I wrote some wrong lines during translation in VB. As you can see below, the project's file SharePointProjectItem.spdata contains the line tagged <SafeControl>.
<?xml version="1.0" encoding="utf-8"?>
<ProjectItem Type="Microsoft.VisualStudio.SharePoint.VisualWebPart" DefaultFile="LeaveWebPartUserControl.ascx" SupportedTrustLevels="FullTrust" SupportedDeploymentScopes="Site" xmlns="http://schemas.microsoft.com/VisualStudio/2010/SharePointTools/SharePointProjectItemModel">
<Files>
<ProjectItemFile Source="Elements.xml" Target="LeaveWebPart\" Type="ElementManifest" />
<ProjectItemFile Source="LeaveWebPart.webpart" Target="LeaveWebPart\" Type="ElementFile" />
<ProjectItemFile Source="LeaveWebPartUserControl.ascx" Target="CONTROLTEMPLATES\LeaveApplicationVB\LeaveWebPart\" Type="TemplateFile" />
</Files>
<SafeControls>
<SafeControl Name="SafeControlEntry1" Assembly="$SharePoint.Project.AssemblyFullName$" Namespace="LeaveApplicationVB.LeaveWebPart" TypeName="*" IsSafe="true" IsSafeAgainstScript="false" />
</SafeControls>
</ProjectItem>
By the way, I'd give a try again this morning, rewriting every thing from scratch and see what I can get.

The issue raised by SPP concerning "unsafe control" was because, during C# project translation, I did include namespace identifiers as per C# syntax.
Removing namespace identifiers from VB code did solve the problem.
Now the project is able to create a custom editor part for my visual web part.

Related

BizTalk: How to get all dlls from an application?

I would like to build an external app (console application) which inform me for the DLLs versions that are used in an BizTalk application.
Of course with a quick search I find some examples which are use the Microsoft.BizTalk.ExplorerOM DLL,
but these examples shows only the DLLs that exist in [BizTalk_Local_MgmtDb].[dbo].[bts_assembly] table which when I see them in BizTalk health monitor they have type System.BizTalk:BizTalkAssembly.
I would like also to add in my app (Console application) the DLLs of type System.BizTalk:Assembly which for example can be a helper class which are not listed by Microsoft.BizTalk.ExplorerOM because, I guess, they not exist in [BizTalk_Local_MgmtDb].[dbo].[bts_assembly] table
Have someone any idea how I can achieve what I want?
I found them, these assembles exists in managmentDB in table [BizTalk_Local_MgmtDb].[dbo].[adpl_sat]
So if I understand the question correctly:
You are creating a utility console application, which uses "Microsoft.BizTalk.ExplorerOM". And your "helper class Assembly" is not being listed in your "Console application" because it is not of type "System.BizTalk:BizTalkAssembly".
I'm afraid that you won't be able to do so, as you can't add a class library as "System.BizTalk:BizTalkAssembly". Here is the error we get when try to do so:
You can make try using "System.Reflection".
For your components to be considered as BizTalk Artefacts, your project should be .btproj
Then deploy your components same way you deploy your biztalk applications.

File or assembly name ****.dll or one its dependenies not found

I have added a new service reference to a vb.net dll after excluding the previous one. While debugging, When I am sending a request through a form, the new reference is not able to create a object.exception is at this line:
Dim ObjPricingService As New PricerWebService.MedicalProductService_V2_0
MedicalProductService_V2_0 is the new service reference. The exception is:
File or assembly name ****.dll or one of its dependencies not found.
Source:mscorlib
the name of the *.dll changes every time I debug..so its a random one. the code is built in Visual Studio 2003.
Please provide a solution.
It sounds strange, that the Library changes the name every time you debug. The best thing todo, is to try to set an standard name (if you wrote the library). Also you can try to
Import PricerWebService
and then to use only
Dim ObjPricingService As New MedicalProductService_V2_0
If this will be not fix your problem, try to upgrade your framework + Visual Studio Version (VS2003 what?).
BTW: It would be great if you can send us the error text ;)

<global namespace> contains definition for __ in multiple code generated files

I just can't get a handle on how to correct this one. It cropped up about a week ago, and I don't know what change I made could have caused this. We use SVN and I rolled back changes I made of possible culprits of these errors but I am still getting the following errors when I build my asp.net webforms project:
The namespace <global namespace> already contains a definition for 'TrxStatus'
The namespace <global namespace> already contains a definition for 'MessageStatusType'
These two errors are repeated 5 times (10 errors total) and the source files are code generated for the loads of webservices we have in the project.
The file names are App_Code.34kjg234jh1.cs (made up, but you get the idea) and at the top of each one it tells me where it is being generated from:
App_Code\App_WebReferences\SomeService\SomeWebService.wsdl
If I go into the .wsdl definition I believe they do all live in the same namespace based off of this line: (Note, I am not a .wsdl wiz, so tell me if I am wrong)
<s:schema elementFormDefault="qualified" targetNamespace="http://www.thirdpartysite.com/Soa/Foundation/">
<s:import namespace="http://www.thirdpartysite.com/Soa/Foundation/MessageDefinition.xsd" />
This is an application inherited from our prior developer (its a one developer shop here, so I usually get to poke around in the dark) so I don't know why we have about 7 different web services in the application, all with that namespace definition and ALL with the offending 'TrxStatus' and 'MessageStatusType'.
I don't want to change the namespaces, because it is the right namespace (I believe), but I also need this conflict to go away. I am not sure which direction to go.
I attempted to go into one of the .wsdl files and change TrxStatus to TrxStatus_Whatever but that gave me this error:
Unable to import binding 'MyWebServiceName' from namespace http://www.thirdpartysite.com/SOA/Foundation
Another possible clue is I am getting a ton warnings from the various web services that say something like this:
The 'http://www.thirdpartysite.com/Soa/Foundation/MessageDefinition.xsd:SomeElementName' element is not declared.
Any suggestions on possible solutions to this? What is the root cause? Please don't tell me I need to re-write all these services....
I'm by no measure an expert, in fact I do very little ASP.NET & Services.
BUT. It sounds as if there are conflicting imports (i.e usings) that are pulling in types with the same names.
proj1: A.SomeType
proj2: A.SomeType
You can add references to both projects and it play just fine (I believe). But the difficulty comes when you import both namespaces because the type names clash.
You can access the correct type by using the global:: accessor.
You can even use global:: in a using statement.
using A = global::[path to correct project and type here]
Not sure if it'll be much use to you, but there's more info on global:: here:
http://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

EntLib 5 Wrap Handler Message Localization

I have been asked, at very short notice of course, to implement exception logging to the Windows Application event Log in one of our products (vb.Net, framework 3.5, WinForms) using EntLib 5. In and of itself this is fine - I can get that working. However, this is for a client who wants messages in Chinese. Certain parts of the app have language resource files and I found a couple of sentences in my MS EntLib Developers Guide book which suggested that I could use an external resource to provide a localised 'friendly' message in a wrap handler within the Exception Handling Block.
Unfortunately there was no mention of how to actually achieve this but it seemed straightforward enough. I added a new resource to a resx file which lives at the project level for the project which is common to all areas of the application and re-built to project so that the satellite assemblies were built. I then specified the name of the resource in the 'Message Resource Name' field within the EntLib configuration console. the problem arises when I try and specify the 'Message Resource Type'.
I clicked on the search button and found the satellite assembly I needed, but it did not get added to the list of loaded assemblies and therefore I couldn't select it. The problem is that none of the places where I've seen this feature mentioned actually demonstrate how to get it working so I'm not sure where I'm going wrong. The search for the assembly will only let me select a dll or exe so I assume I am supposed to reference the satellite assembly somehow but how do I do this if it won't add it to the list of loaded assemblies?
One point to note is that we have a main executable which then calls numerous class libraries to load areas of functionality as required, and the config file we use throughout is the one which belongs to the main executable. Is it the case that you can only use satellite assemblies which are related to the assembly that the config file belongs to?
I haven't yet fully utilized this feature yet but just something to check, are you using the fully qualified name of the assembly?
EDIT: A potentially applicable link - http://entlib.codeplex.com/discussions/67460

.NET 4.0 - CultureNotFoundException

I have migrated my ASP.NET MVC 2 project to VS 2010 + .NET 4.0.
Now when i start the application i get a lot of "CultureNotFoundException" in IntelliTrace and Output/Gebug window :
A first chance exception of type 'System.Globalization.CultureNotFoundException' occurred in mscorlib.dll
I know what "A first chance exception" means, but when i try to debug(added "CultureNotFoundException" into Bebug/Exceptions[Thrown]) why ex. is thrown i got this detailed exception text:
System.Globalization.CultureNotFoundException occurred
Message=Culture is not supported.
Parameter name: name
designer is an invalid culture identifier.
Source=mscorlib
ParamName=name
InvalidCultureName=designer
StackTrace:
at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
InnerException:
I wonder why .NET is trying to create CultureInfo with name "designer"?
Isn't it bug?
I had a similar issue with the CultureName "UserCache". To resolve this I deleted all the folders from in here:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
For other people that have this problem, this is usually an exception that is ignored.
Go to the Debug menu -> Exceptions... and ensure that you have everything unchecked for the Exception list.
This is actually by design in System.Web (at least up until .NET Framework v4.0), not necessarily the best approach, but it works.
You can find a more detailed description here, but it basically happens because ASP.NET checks every single folder to see if it contains satellite assemblies, and throws an exception otherwise.
Given that satellite assemblies live in folders with predictable names, one would wonder why they would decide to do this rather than only check folders that match the pattern, particularly since handling exceptions is rather expensive computationally compared to a simple conditional check.
I was curious as to the cause to see if there was something I could personally do to eliminate this particular annoyance.
The Exception is a side effect of calling, "System.Web.UI.Util.IsCultureName(name)"
The first time it's called in my MVC3 application is in regards to a directory called "UserCache", which is in the same directory as several directories with the expected culture names "en-US", etc. .Net is trying to find Satellite directories for the application.
It's called multiple times, even relating to files that are culture files, "EditorLocalization.bg-BG.designer.cs" for example (actually all of these that are in App_GlobalResources). [ What the code does here is to take all the files in App_GlobalResources, and see if the file ends in a CultureName, again calling IsCultureName.
So there's nothing you can really do to avoid this... In production where the .cs classes won't be there, perhaps it won't happen. It certainly slows down startup quite a bit, though!
In any case, in my mind it's a total bug that Microsoft throws an exception inside, "IsCultureName().
Go to the Debug -> Options in Visual Studio and check "Just My Code".
I found that turning on "Enable Just My Code" in the Debugging section of the Visual Studio 2017 options worked for me. That just hides those exceptions, which are part of the normal operation of the framework.
I had a similar issue with the "CultureNotFoundException". To resolve this I had to delete all the folders from in here additionally:
%LocalAppData%\Local\Temp\Temporary ASP.NET Files
Deleting from here wasn't enough:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
I had this error message:
'ViewBag.XXXXX' threw an exception of type 'System.Globalization.CultureNotFoundException' dynamic {System.Globalization.CultureNotFoundException}
The inner message said:
The culture is not supported.\r\nParameter name: name\r\nneutral is an invalid identifier culture.
The problem was that there was an invalid definition of the assembly culture in the AssemblyInfo.cs file:
[assembly: AssemblyCulture("neutral")]
To fix it, just leave empty the "culture" parameter like this:
[assembly: AssemblyCulture("")]
That fixed the problem for me.
I think it's the actual designer that messed things up. Try searching across your solution for "designer" string to see if any XML/HTML attributes have their values set to this string.
It seems as the problem was a bug in VS 2010 Beta 2.