When I try to compile using Visual Studio 2005 Express Edition the example below that I extracted from http://msdn.microsoft.com/en-us/library/vstudio/bb397680.aspx, VS throws out 9 errors:
1) 6 errors are about the 6 gets/sets "must declare a body because it is not marked abstract or extern", and
2) 3 errors are about the { and } after the new StudentName, i.e. A new expression requires () or [] after type.
Please help. Thank you.
The sample there requires a newer compiler, it uses features not available with the compiler used by VS 2005. That document is part of the VS 2008 documentation, so VS 2008 or newer should be able to compile it.
Related
The project was created using Visual C++ 6.0 and I'm new to using Visual C++. Now in my project, I set up Visual C++ on Windows 10, but when rebuild all below error C2259 throw. Please help me how to fix this error C2259. Thanks in advance.
D:\VS98\VC98\ATL\INCLUDE\atlcom.h(1827) : error C2259: 'CComObject' : cannot instantiate abstract class due to following members:
D:\VS98\VC98\ATL\INCLUDE\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class ATL::CComObject >::CreateInstance(void *,const struct _GUID &,void ** )'
At last, found the issue. One of the method definitions is different.
To resolve,
Check the function declarations and definitions prototypes in the .cpp,.h and .idl files. Also, check if they are same in all the 3 files.
.idl file we usually miss out on modifying since the search result doesn't show the method.
Well , the picture speaks for itself.
Silverlight project
VS 2015 ( tried also with 2013 and 2012 )
It is a documented restriction, the constructor you are trying to use is not supported in Silverlight version 5. From the MSDN article:
Supported in: 4, 3
Not crystal why it was dropped, probably has something to do with it being [SecurityCritical].
Why your IntelliSense still shows it is hard to guess, I certainly can't repro that. You probably ought to verify the path to the mscorlib reference, mine points to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0\mscorlib.dll
So I recently got Visual Studio 2012. I converted a Visual Studio 2010 solution to a Visual Studio 2012 project. It was working before I converted it.
I have this line of code:
this->Text = global::ProjectName + " (" + global::Type.ToString() + ") - Path Creator 2.0";
where global::Type is:
ref class global {
public:
static Rct3PathType Type;
...
};
...and Rct3PathType is:
enum class Rct3PathType {
Basic = 0x02060206,
Extended = 0x05060506,
Queue = 0x01070107
};
I get an error at compile time where ever I have called global::Type.ToString() saying "error C2228: left of '.ToString' must have class/struct/union". Considering this all compiled completely well BEFORE switching to Visual Studio 2012, I'm not sure what the issue is! :(
Also, when I try to run the last successful build (which was built with Visual Studio 2010), I get runtime error at startup saying "The program can't start becayse MSVCR100D.dll is missing from your computer." I know this probably doesn't relate to the issue at hand, but does anyone know why this may be happening as well?
Thanks for your help,
Alex
"error C2228: left of '.ToString' must have class/struct/union": enum class is also the syntax for a C++11 enum. To make it a C++/CLI enum, give it an accessibility specifier, which is not allowed on a C++11 enum. In other words, private enum class or public enum class will change it from a C++11 enum to a C++/CLI enum. This wasn't a problem in VS2010 because it doesn't support C++11 enums.
"The program can't start because MSVCR100D.dll is missing from your computer.": VS2012 uses a different C runtime than VS2010. MSVCR100D is the Microsoft Visual C Runtime version 10.0, Debug version. This DLL is installed with VS2010, there is no other way to get it. If you have an old Release build, you can get the runtime redistributable from Microsoft (x86 or x64), and install that to make it run. (That will be MSVCR100.dll, no "D" at the end.)
I am writing a managed DLL in VC2010 (i.e. /CLR is enabled for a VC++ DLL project). Following code wouldn't compile:
System::Collections::Generic::List<int>^ my_list;
for each(auto elem in my_list)
{
}
It raises error C3539: 'auto': a template-argument cannot be a type that contains 'auto'.
I don't understand the reason. I tried compiling the same in VS2012, and it raises same error (which is not appropriate error).
Why compiler fails to deduce the type for a colleciton? The same type of code would work in C# with var keyword.
First, the most importand point from the comments:
presented code does compile in VS2013 c++/cli dll .net 4.5 (Zee, 2014-05-03)
When you compile C++/CLI, which is the .NET binding for C++, you are using a different feature set of the Microsoft compiler. Whether something works either
when /clr is in effect
or, additionally, when you're using a "managed" construct (as in your code)
has nothing to to with if the "normal", native, MSVC compiler accepts it.
So as for "why": It would simply appear that auto type deduction did not work for the managed handle types in VS2010 and VS2012, but, according to Zee's comment, has then been implemented in VS2013. (A quick Search Engine check didn't find any official statement wrt. this, so I may be wrong.)
I'm tyring to convert a MSVC project from VS 2005 to VS 2008. It contains a IDL file that outputs a header and stubs used for RPC. The VS 2005 project uses MIDL.exe version 6.00.0366. The VS 2008 project uses MIDL.exe version 7.00.0500.
Here's the problem: MIDL v6 outputs the following prototype for me to implement in my server code:
HRESULT PRC_Function(UINT input);
MIDL v7 with the same command line outputs this prototype:
HRESULT RPC_Function(handle_t IDL_handle, UINT input);
I don't want to have to go through and add the handle_t parameter to all my existing implementations. (Plus I still need the implementations to compile with VS 2005 for a while longer.)
Question: How can I get MIDL.exe v7 to output the same RPC server prototypes as v6?
Looks like I can answer my own question...
MIDL v6 appears to automatically default the handle type to auto_handle for the server prototypes. MIDL v7 does not, so the solution is to use a Server.acl file with the auto_handle setting in it. This outputs a Server.h file with function prototypes that is the same between MIDL v6 and v7.
However, it also outputs a warning indicating that "auto_handle" has been depreciated. Instead I used implicit_handle(handle_t IDL_handle).
Too bad this site doesn't give me badges for answering my own questions. Nor can I flag my own answer as the correct answer.
The handle_t IDL_handle is for the explicit RPC binding handle. On the server side, you can do cool stuff with it like pull the calling client's token for impersonation through the various RPC functions, but if you don't need to use it, it is fine to just set it as an unreferenced parameter (UNREFERENCED_PARAMETER(IDL_handle);). It seems like implicit binding handles are deprecated now.
On the client side, you use the binding handle you get when you bind to the RPC server for the IDL_handle parameter.