[Mono-dev] Equivalent of csc /link for mcs (COM interop)?
Peter Dillinger
pcd768 at gmail.com
Tue Nov 13 17:27:22 UTC 2012
(This message was not accepted from my work email and or from the
forum interface. Trying personal email...)
In investigating the ability to drop in mcs as a replacement for csc
(currently trying out mono 2.11.4), I've run into issues in compiling
things from some Microsoft C# 4.0 code samples that involve COM
interop. Here's a simplified example:
public class Program
{
public static void Test(Microsoft.Office.Interop.Excel.Application xl)
{
xl.Columns[2].AutoFit();
}
public static void Test2(Microsoft.Office.Interop.Excel.Range r)
{
r.Value = 42;
}
}
Compiling this with csc requires -link (aka /link), as seen here:
$ cp /cygdrive/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio\
10.0/Visual\ Studio\ Tools\ for\
Office/PIA/Office12/Microsoft.Office.Interop.Excel.dll .
$ /cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319/csc.exe -target:library
-link:Microsoft.Office.Interop.Excel.dll Program.cs
Microsoft (R) Visual C# Compiler version 4.0.30319.17929
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.
$ /cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319/csc.exe -target:library
-r:Microsoft.Office.Interop.Excel.dll Program.cs
Microsoft (R) Visual C# Compiler version 4.0.30319.17929
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.
Program.cs(5,23): error CS1061: 'object' does not contain a definition
for 'AutoFit' and no extension method 'AutoFit' accepting a first
argument of type 'object' could be found (are you missing a using
directive or an assembly reference?)
$
So trying to compile this with mcs, it seems the closest we can come
to -link is to replace with -r, so we would expect it to fail
similarly to mcs above, which it does for 'Test' but 'Test2' has other
problems:
$ /cygdrive/c/Program\ Files\ \(x86\)/Mono-2.11.4/bin/mcs.bat -target:library
-r:Microsoft.Office.Interop.Excel.dll Program.cs
Program.cs(5,23): error CS1061: Type `object' does not contain a
definition for `AutoFit' and no extension method `AutoFit' of type
`object' could be found. Are you missing an assembly reference?
C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\mscorlib.dll (Location of the
symbol related to previous error)
Program.cs(9,11): error CS1546: Property or event
`Microsoft.Office.Interop.Excel.Range.Value' is not supported by the
C# language
D:\scalability-csharp\test-cs4codesamples-orig\samples\This sample
shows how to use the\C#\Microsoft.Office.Interop.Excel.dll (Location
of the symbol related to previous error)
Program.cs(9,11): error CS0200: Property or indexer
`Microsoft.Office.Interop.Excel.Range.Value' cannot be assigned to (it
is read-only)
Compilation failed: 3 error(s), 0 warnings
$
This leads me to two questions:
(1) Is there any plan to support an equivalent of csc -link (aka
/link)? Or is there some other work-around I don't know about?
(2) It appears that the "is not supported by the C# language"+"cannot
be assigned to" issue a bug. Is that correct? (If so, I can file
it.)
And a bonus question:
(3) For general C# language issues where csc willingly compiles
something that is arguably not adherent to the language spec, but mcs
rejects it, does the Mono team consider that a valid bug or
enhancement request? (Is there a "duplicate Microsoft's bugs" mode
for mcs?)
Thanks for your help,
Peter Dillinger | Senior Engineer
Coverity | 185 Berry Street | Suite 6500, Lobby 3 | San Francisco, CA 94107
The Leader in Development Testing
Read our profile in Forbes, Coverity Gets Code Right 25% Faster
More information about the Mono-devel-list
mailing list