InitializeComponent() broken when refering Sharepoint.dll - c#

Morning!
I am trying to program against sharepoint with Linq, but have a starting problem.
I guess this might be a newbee problem, but i am one so dont shoot me.
I have created a WPF app and did not add any code. I then add a reference to Sharepoint.Client.dll and Sharepoint.Linq.dll. After this is done i get the red squigel line under InitializeComponent() telling me its not existing in the current context.
This is only a problem in WPF not regular old Windows application.
Spec:
Application is .NET 3.5 since sharepoint does not support 4.0.
Application is x64 as sharepoint is x64 only.
Everything else is default.
Any ideas?
Thanks

First of all, could you check if the target framework of your project is actually set to .Net 3.5?
Secondly, make sure that the Build Action for the xaml file (in the Properties window) is set to "Page"
If neither of these options solve your issue, could you please post the root node declaration of your xaml file (i.e. <Window x:Name=....). There might be a problem there.

Related

Migrate Xamarin Forms Effect to .NET MAUI

For a Xamarin Forms application, I have been using a solution to track touch using code from an example out of Microsoft's Xamarin Forms Sample Project, specifically the Touch Tracking Effect sample.
I took that sample and simplified it down to just directly starting up with the BoxViewDraggingPage.xaml from App.xaml.cs and removing all other XAML files. That compiled and ran fine.
I then created a .NET Maui App with the same BoxViewDraggingPage (and the same TouchActionEventArgs.cs, TouchActionEventHandler.cs, TouchActionType.cs, and TouchEffect.cs) as was in the Xamarin Forms version.
I added the same TouchEffect.cs files that were in the sample for the specific platforms (iOS also has a TouchRecognizer.cs file)
When running it at that point I got the following:
So then I tried following the instructions for Migrating Xamarin.Forms Effects. The explanation for how Xamarin.Forms effects were set up matched perfectly, but it was unclear to me from that page what class the section titled "Effects in .NET MAUI" was replacing since it had a different class name than the previous code snippets earlier in the article. It seemed like it is replacing the FocusEvent class in the shared platform code and then specifies the platform specific code within #if platform sections (#if WINDOWS, #if __ ANDROID __, etc.) and so I am guessing that means the TouchEffect.cs files are no longer needed in the platform specific folders.
I didn't have a chance to find out if that was the case or if it works, because when I try to compile, I get:
I don't find any missing Nuget packages or assemblies when I tried searching. If I click the dot after Platform, I get the following choices, with instructions to use the navigation bar to switch contexts:
But I am already targeting net6.0-windows10.0.19041.0:
so I'm not sure why it says Not Available for that.
So, I am stuck trying to get this to work.
I am looking either for a solution to get the sample code working as it is in the Xamarin.Forms project, but for .NET MAUI (whether that be set up how the sample originally had it or how it is described in the Migrating Xamarin.Forms Effects link) - it could be that I am missing something simple in how to get that Microsoft.Maui.Controls.Compatibility.Platform.UWP piece to compile.
Or, the other possibility is that same link says that .NET MAUI Handlers can also handle this type of scenario. So if someone can show all the pieces that would need to be modified in order to do the same solution but using .NET MAUI Handlers, I am open to that. But it seems that the easiest path, though, should be to get the Effects working in .NET MAUI since everything is already written that way. I am just leaving both options open in looking for a solution.
EDIT:
OK, I figured out why the UWP portion had red squiggles under it. I figured out what "using the navigation bar to switch contexts" in the above screenshot meant. It meant I needed to select the context in the dropdown pictured below:
However, this just moves the squiggles to PlatformEffect and I cannot figure out what to do with the context or anything else to resolve that:
OK, I found out that PlatformEffect now inherits from Microsoft.Maui.Controls.PlatformEffect instead of the separate Platform inheritances shown in the Migrating Xamarin.Forms Effects example. That example is out of date and I didn't realize that and so it was confusing me.

Why is objectlistview not working?

I am trying to use object list view, and have followed everything. I have put the dll into my references, and have gone as far as putting it in my debug, and release folder.
The problem I am having is that it keeps giving me this error:
Is there anything I am doing that is wrong?
Take a look at this discussion thread.
Someone said they checked the FAQ and subsequently "changed the target to the full profile." It sounds like if your project is built against a client profile, you could run into this issue. I haven't downloaded the ObjectListView source myself and tried to build it to see if that's actually the case.
Check that your project is building against the full .NET framework, and not a "client profile". I use VS2012 now, which creates new projects with the full profile already set. But if you happen to be using VS2010, it created new projects with a target framework of "client profile" by default.

When compiling solution, previously working assembly reference / using no longer works [duplicate]

My C# WinForms solution has two projects.
A DLL which is the main project I'm working on, and an executable WinForms I call "Sandbox" so that I can compile/run/debug the DLL easily in one go.
I'm working in .Net 4.0 for both projects.
Everything was working fine until I added some seemingly innocent code, and a reference to System.Web in the DLL.
Now my Sandbox project can't see the namespace of the DLL project. I didn't change anything which I believe should have affected this.
If I delete the project reference to the DLL from the Sandbox references and re-add it, then the red underlines all disappear and the colour coding comes back for all my classes etc; but as as soon as I try to build the solution, the whole thing falls apart again.
When I right-click the DLL project in the Sandbox's references and view in object browser, I can see the namespace and all the stuff in there.
I have a feeling this might be some sort of bug?
Is this some sort of VS2010 bug? I had this same issue a few months ago and I could only fix it at the time by making a whole new project and re-importing my files. This time, however, I have a bajillion files and will only do that as a last resort!
Edit:
After panickedly going through and undoing all my changes, trying to find what caused the problems, it seems to be this line:
string url = "http://maps.google.com?q=" + HttpUtility.UrlEncode(address);
If I comment out this line, then I get no namespace errors and the project builds fine. I can't see anything wrong with this line though.
I'm ready to declare this a bug in VS2010, this has bitten way too many programmers already. The fix is easy: Project + Properties, Application tab, change Target Framework to ".NET Framework 4" instead of the Client Profile that is selected by default.
System.Web is not included in the client profile. Having this option in the first place is quite silly, the client profile is only 15% smaller than the full version of .NET 4.0. Having it selected by default is even sillier. But I digress.
UPDATE: mercifully this all got fixed in VS2012. Which no longer makes the client profile the default for a new project. And the client profile got retired completely in .NET 4.5, good riddance.
Check to make sure that both projects are using the non-client profile for their target framework (go to each project's properties to do this).
One possibility is that the target .NET Framework version of the class library is higher than that of the project.
I faced this problem, and I solved it by closing visual studio, reopening visual studio, cleaning and rebuilding the solution. This worked for me. On some other posts, I have read the replies and most of users solved the problem by following this way.
Try building only the project with the Sandbox dll first independently.
Then point your executable project to the required dll and ensure copy local is set to true. in reference settings.
Tthen build the executable project.
Changing the target framework from the ".NET Framweork 4 Client Profile" to ".NET Framework 4" worked for me with a similar problem. I agree that the client profile doesn't seem to have much of an advantage to using it. I seem to get nailed with weird errors that I hunt for until I remember that Visual Studio defaults to the client profile. I guess the moral of the story when getting an error is: if "Rebuild Solution" doesn't work, check the Target framework...
If you tried already doing the Framework change, and still not worked, I hope this works for you (as it did for me): Simply add the necessary references from within your projects. Very obvious but I was doing it wrong until I found what was the issue.
I just had this issue and it turned out to be I had multiple namespaces being used that had the same object name (i.e. business objects had the same names as mvc models);
Fully qualifying the names fixed the issue for me.

Grid is not supported in a Windows Presentation Foundation (WPF) project

I am learning how to create a Class Library (Windows Store apps) and used a UserControl template to add a user control to it.
Then I added a Grid tag to accompanying XAML. However, the tag is underlined with blue squiggles and when I hover over the tag there is
Grid is not supported in a Windows Presentation Foundation (WPF) project
tooltip shows up.
The library seems to build without errors. I've added the library to an application and use the control in its code. The application is also builds just fine. However, when I run the application I get XamlParseException exception.
I am using Visual Studio 2012 RTM. Both the library and the application reference only two standard assemblies (.NET for Windows Store apps and Windows).
What I might done wrong and how should I fix the library?
In my case I switched from Debug to Release, and then back, and the error was gone.
Go to "Build > Configuration Manager..." and Make a new platform for x86 for all your projects.
It doesn't have to be the active one, you can leave that as Any CPU.
Hope it works as for mine...
I've recently had the same error and found the following in the output window:
10>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFX.targets(268,9): error MC6000: Project file must include the .NET Framework assembly 'WindowsBase, PresentationCore, PresentationFramework' in the reference list.
The solution for me was to add the missing references to my project.
For me it helped to set the "Target framework" in application-properties to .NET 4.0
This appears to be a bit of a "catch-all" for a number of XAML resource errors. I've found two causes so far:
Declaring a Resource outside of the appropriate context- e.g. directly in a UserControl tags, not UserControl.Resources.
Forgetting to include the correct namespace for the "unsupported" class. Example in a basic ResourceDictionary, with no sys namespace defined:
<ResourceDictionary>
<sys:string>I'm not supported</sys:string>
</ResourceDictionary>
I was able to solve my similar issue of..
UserControl is not supported in a Windows Presentation Foundation (WPF) project
.. by removing the PresentationFramework reference and re-adding it via nuget.
[Reposting comment as answer]
I was able to complete the steps with no issues, and it appears you were able to as well. Perhaps there was some other inadvertent modification/setting that was made?
This is xaml getting itself confused. I have the error on one project and not on another. Have a look at the top of the xaml before the grid error and see if there are any references to other controls. Try making a modification that will cause and error and rebuilding one of those controls. Then put it back the way it was to get a succesful build and see if this makes the grid error go away. (it did for me)
Much Like Felix D.s answer, I found from the .csproj file a reference was removed.
Obviously replace the 3 with your needed framework, or use the project properties to set the version ( i think that adds this reference )
Evil Dog Pie was step 1 for me, as some other issues came up. There is always a heap of information in the output log
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
This problem is due to the low version of .NET that you have chosen in your project.
To solve the problem, select the Project from the up menu and then select your Project Properties and from the part of Target Framework select higher version of .NET Framework!
I hope your problem is solved.
Yours sincerely

Expression blend convert example from Silverlight into WPF

Hey! I was looking at a cool layout example in particular the V3FluidLayout.xaml found inside this set of examples : http://gallery.expression.microsoft.com/en-us/DynamicLayoutTrans
Anyhow - this appears to be a silverlight app - it runs within a browser. I am trying to pull the V3FluidLayout example into a WPF app - and struggling.
I "add an existing item" pulling the .xaml file into my project. When it goes to compile it, the following errors are found :
Are these artifacts Silverlight? The following is the xaml code within the V3FluidLayout.xaml file
http://pastebin.com/h9ujUax6
Can anybody help me pin why this is not working - and how I can convert that xaml code to work inside my wpf app.
Thanks
Andy
Basically (and from only a quick glance), you'll need a reference to the WPF versions of System.Windows.Interactivity and Microsoft.Expression.Interactions - they are part of Blend. Actually look at the references of that project and find the exact same references, only for WPF.
It looks like they contain pretty much the same classes for both WPF and Silverlight, so I think it should work in the end.
Add references to the interactivity assemblies found here:
C:\Program Files (x86)\Microsoft SDKs\Expression\Blend.NETFramework\v4.0\Libraries
You need to install the Blend SDK to get them, the come with Blend also.

Categories