I have a really tough question. How would I add a class in Visual Studio for Mac?
More specifically, how do I reference any class?
I'm going through the instructions here. It says there is an Audio Player example that uses the AVAudioPlayer class.
It doesn't specifically say how to add that class but going to the Projects > Add Reference menu and typing Audio in the search box shows nothing:
This is the instruction page I've referenced:
https://learn.microsoft.com/en-us/xamarin/mac/app-fundamentals/sounds
The page also says it's an example but I don't see any code only an API reference.
Apple APIs
https://developer.apple.com/documentation/avfaudio/avaudioplayer#see-also
https://developer.apple.com/documentation/avfaudio/avaudioengine
UPDATE:
I think I might have figured it out.
The class looks like it was in AVFoundation package not AVFAudio:
To use it you have to put:
using AVFoundation;
at the top of your class
Then in your code you can use:
var player = new AVAudioPlayer();
Or it looks like you can use the full namespace to create an instance:
var player = new AVFoundation.AVAudioPlayer();
I'm still getting errors so I don't know if that's it or not.
I also added some Nugen libraries like Xamarin.CommunityToolkit but I don't see them referenced in so I don't know if that's necessary.
Update 2:
It looks like the instructions for that are here:
https://learn.microsoft.com/en-us/visualstudio/mac/nuget-walkthrough?view=vsmac-2019
Here are the errors I'm getting:
/Applications/Visual
Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Microsoft.Common.CurrentVersion.targets(5,5):
Warning MSB3276: Found conflicts between different versions of the
same dependent assembly. Please set the "AutoGenerateBindingRedirects"
property to true in the project file. For more information, see
http://go.microsoft.com/fwlink/?LinkId=294190. (MSB3276) (project)
/Users/me/project/packages/Xamarin.CommunityToolkit.1.1.0/build/PreserveXamarinCommunityToolkit.cs(12,12):
Error CS0246: The type or namespace name 'PreserveToolkitAttribute'
could not be found (are you missing a using directive or an assembly
reference?) (CS0246) (project)
Side note:
There doesn't seem to be much activity here on SO, so I attempted to visit the Visual Studio forums and to post you have to join the Microsoft docs network. Here's some of the details when attempting to sign up. They didn't mention this before signing up.
I'm looking at sample code here:
https://blogs.msdn.microsoft.com/paolos/2010/01/29/how-to-boost-message-transformations-using-the-xslcompiledtransform-class/
But I can't get the helper routine to compile because this statement:
using
Microsoft.BizTalk.CAT.Samples.DynamicTransforms.Helpers.Properties;
is giving error:
The type or namespace name 'Properties' does not exist in the
namespace 'Microsoft.BizTalk.CAT.Samples.DynamicTransforms.Helpers'
(are you missing an assembly reference?)
If I comment that line out, then I get errors on the class "customBTXMessage" (the type or namespace ... cannot be found...)
That sample is for BizTalk 2010.
You should not need to do that for BizTalk 2013 and up, as it already uses XSLT Compiled transform.
This actually caused a few problems as per Known issues in BizTalk Server 2013
To run lots of map for testing purposes I would use BizUnit
I'm new to Visual C++. I have two separate projects (let's call the first Converter and the second TreeGridView). I have this line of code in the Converter project:
private: AdvancedDataGridView::TreeGridView^ treeGridView;
which throws this error on 'AdvancedDataGridView':
name followed by '::' must be a class or namespace name
I think I understand the error - Visual C++ can't find a class or namespace called 'AdvancedDataGridView' right?
I have a separate Visual Studio project called TreeGridView which has 3 C# projects included in it. One of the projects has an assembly name of 'ExpandableGridView' and a default namespace of 'AdvancedDataGridView' and an output of type Class Library. Another project has an assembly name of AdvancedDataGridView and a default namespace of AdvancedDataGridView and an output type of Windows Application.
Being new to Visual C++ and the codebase I'm using, I'm not sure how to make the error go away. The TreeGridView project (the one with 3 c# projects) does generate an ExpandableGridView.dll file which I've added a reference to in my Converter project, but the error persists. Intellisense doesn't find AdvancedDataGridView at all. Any ideas?
Additional info: When adding the ExpandableGridView.dll as a reference, I get a yellow warning triangle icon on the reference and 'Full Path' in the properties says
The "Microsoft.VisualStudio.ProjectSystem.References.UnresolvedAssemblyReference" reference
could not be resolved.
Solved. I had two references to the same ExpandableGridView dll file - got rid of both of them, then added the latest dll again - after that the error and warning I mentioned above went away.
You're trying to XOR a type with a variable? Pointers are declared using type*, not type^.
See http://www.cplusplus.com/doc/tutorial/pointers/ for a tutorial on C and C++ pointers.
With the risk to fall into too specific question...
Given a C++ MFC (mixed, not shaked) project compiled with /CLR, I have 200 classes already defined.
When I add a new empty class to this project, an error raises when I compile and execute in debug mode.
An unhandled exception of type 'System.IO.FileLoadException' occurred
in Unknown Module.
Additional information: Could not load file or assembly 'ProjectA,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. Could not find or load a type. (Exception from HRESULT:
0x80131522)
ProjectA is the name of the MFC project itself. There is no reference to any ProjectA assembly on project configuration, and there is no reference to another custom assembly.
This project only have references to some .NET Framework assemblies, in order to allow that some of custom defined classes in the project can use CLR classes.
Then, the question is...
Do you know whether there is any limitation of class number on a MFC C++ project?
EDIT:
As I say in comments, in release mode the compilation succeed without errors.
Also, I clean, build, clean, close Visual Studio, reboot computer... and the problem still appears.
If I keep in 200 classes, there is no error. When I go to 201, the error appears.
Currently I'm trying to reproduce in a new default MFC project, adding classes till arrive to 200, to confirm that there is a real limitation.
EDIT 2: ERROR FIXED
Great. #MSX and #frymode show me how avoid the error with his comments.
In the Visual Studio development environment (source / source):
Open the project's Property Pages dialog box.
Click the C/C++ folder.
Click the Code Generation property page.
Modify the Enable String Pooling (/GF) property.
Thank you guys!
The /GF hack is a known workaround for this problem. It is however not a correct one, you are putting a band-aid on a heavily bleeding wound. Pretty important that you heal the problem instead of putting a patch on it, this heavily affects the way your program runs at runtime as well.
The problem maker is the <Module> class, an internal class that the C++/CLI compiler generates. You can see it with ildasm.exe or a good decompiler. This class is required as a home for declarations in your program that are not class members, valid in native C++ but not supported by the CLR. Which demands that every variable or function declaration is a member of a class. The C++/CLI compiler solves it by moving such a declaration into the <Module> class.
There is however a limit on the number of members in a class, they are represented in the metadata of the .NET assembly with a metadata token. An index into other tables. The upper byte identifies the table number, the lower bytes are the index in the table.
You exceeded that limit. This is bad.
A problem with the /clr compile option is that it works too well. It is capable of compiling any C++03 compliant native C++ code to MSIL. Such code will be just-in-time compiled to machine code by the jitter, just like normal managed code. It is however not verifiable code and it doesn't act like managed code at all, you can blow up your program with pointer fumbles just as easily. And above all, it is not code that's optimized with the native C++ back-end. Only the jitter optimizer has a shot at improving that code, it cannot do nearly the quality job that the native C++ optimizer can do, given that it runs with a hard upper limit on how much time it can spend on doing that job.
Have a look-see with a decompiler to see what ended up in that <Module> class. That's going to be overwheliming at first, you know you've got a big one right now. You fix this problem by spending more time segregating the code into the managed parts and the native parts. Where the native code should be compiled without /clr in effect. It is a per-source file setting, you can even switch back-and-forth in a single source code file with #pragma managed. The simplest way to segregate is by keeping your native code in its own library or DLL.
This link shows that there's no limit to the number of types you can have in a namespace (not a project). Considering, that a namespace can be split across different assemblies, you could, at least in theory, have an unlimited number of types. However, this post affirms that the maximum number of classes in a .DLL
is 16777215. Probably, you'll run out of memory before you reach that number of classes :)
Just for information: there seems to be a limit to the number of fields per class, though.
P.S.:
Here's the solution to your problem taken from this link
Open the project's Property Pages dialog box.
Click the C/C++ folder.
Click the Code Generation property page.
Modify the Enable String Pooling property.
Can't seem to add this web service in visual studio 2010 - what happens is :
C:\>wsdl [http://opensearch.addi.dk/1.0/opensearch.wsdl]
Error: Unable to import binding 'osSearchServiceSoapBinding' from namespace 'http://oss.dbc.dk/ns/opensearch_wsdl'.
- Unable to import operation 'search'.
- Group 'elementsAndRefinementsGroup' from targetNamespace='http://purl.org/dc/terms/' has invalid definition: Circular group reference.
I don't know much about this type of Web Services (use REST), but the guys that made this service use PHP and didn't see a problem or couldn't explain it to me.
I have look over the .xsd files but find them to verbose.
There is som PHP code in there but I do C# for the most part so I can't find heads or tails in them either.
Now the question is: How can I get this to work ? - if its not possible to fix so that I can import this in VS can someone show me how to do it manually in C#?
The wsdl from the opensearch is not very Visual Studio friendly. There is, as you mention, a circular reference in the schema. I am doing an .NET implementation of this for another library (AALBIB) - i downloaded all the .xsd files and manually edited the circular reference out, hoping that i will never use that part of the system. Then generated proxy classes using thewsdl tool