Bug 343 - VBNC99999: Internal compiler error. When casting with CType or DirectType
Summary: VBNC99999: Internal compiler error. When casting with CType or DirectType
Status: RESOLVED INVALID
Alias: None
Product: Compilers
Classification: Mono
Component: VisualBasic ()
Version: unspecified
Hardware: PC Linux
: --- minor
Target Milestone: ---
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2011-08-19 19:02 UTC by Eric Mangold
Modified: 2011-09-02 19:09 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Eric Mangold 2011-08-19 19:02:25 UTC
I'm trying to compile a very simple VB.Net application originally authored with VS2008, using xbuild with Mono 2.10.2 and vbnc 0.0.0.5943.

Originally I have the line: 

client.BeginConnect(Host_Box.Text, port, AddressOf ConnectionDone, client)

Which results in the following compiler error:

/home/teratorn/code/ampsharp/ampsharp-ng/doc/examples/VBSumClient/VBSumClient.vbproj (default targets) ->
/home/teratorn/altsys/lib/mono/3.5/Microsoft.VisualBasic.targets (CoreCompile target) ->

	/home/teratorn/code/ampsharp/ampsharp-ng/doc/examples/VBSumClient/Client.vb (17,16): error VBNC99999: After removing narrowing (except object) candidates for method 'BeginConnect', nothing was found
	/home/teratorn/code/ampsharp/ampsharp-ng/doc/examples/VBSumClient/Client.vb (17,16): error VBNC99999: Tried to select using invocation list: '(System.String, System.Int32, DelegateUnresolvedType.vbnc, System.Net.Sockets.TcpClient)' of 3 initial candidates
	/home/teratorn/code/ampsharp/ampsharp-ng/doc/examples/VBSumClient/Client.vb (17,16): error VBNC99999: Candidate #1: BeginConnect (System.Net.IPAddress, System.Int32, System.AsyncCallback, System.Object)
	/home/teratorn/code/ampsharp/ampsharp-ng/doc/examples/VBSumClient/Client.vb (17,16): error VBNC99999: Candidate #2: BeginConnect (System.Net.IPAddress[], System.Int32, System.AsyncCallback, System.Object)
	/home/teratorn/code/ampsharp/ampsharp-ng/doc/examples/VBSumClient/Client.vb (17,16): error VBNC99999: Candidate #3: BeginConnect (System.String, System.Int32, System.AsyncCallback, System.Object)


So, it seems to be having trouble finding the right signature for the BeginConnect method (because of a DelegateUnresolvedType.vbnc thing?)

So I tried to cast the delegate to AsyncCallback as in:

client.BeginConnect(Host_Box.Text, port, CType(AddressOf ConnectionDone, AsyncCallback), client)

But this crashes the compiler with an internal error:

/home/teratorn/code/ampsharp/ampsharp-ng/doc/examples/VBSumClient/VBSumClient.vbproj (default targets) ->
/home/teratorn/altsys/lib/mono/3.5/Microsoft.VisualBasic.targets (CoreCompile target) ->

	/home/teratorn/code/ampsharp/ampsharp-ng/doc/examples/VBSumClient/Client.vb (17,56): error VBNC99999: Internal compiler error close to this location
	/home/teratorn/code/ampsharp/ampsharp-ng/doc/examples/VBSumClient/Client.vb (17,37): error VBNC99999: Internal compiler error close to this location
	: error VBNC99999: Unexpected error: There has been an internal error in the compiler: 'Use the other overload.' caused by the line: (17,65)


Not sure what other information I could provide. The project I'm trying to compile is just a very simple VB.Net WinForms app that is an example program which exercises a C#/.NET library (ampsharp). Here is the code in question: 

http://bazaar.launchpad.net/~teratorn/ampsharp/ampsharp-ng/files/head:/doc/examples/VBSumClient/

Or `bzr branch lp:ampsharp' and try to `xbuild ampsharp/doc/examples/VBSumClient/VBSumClient.vbproj'
Comment 1 Rolf Bjarne Kvinge [MSFT] 2011-09-02 19:07:39 UTC
Casting an addressof expression to a delegate is not legal VB (Visual Studio shows an error for it too, albeit a better error).

This however works:

client.BeginConnect(Host_Box.Text, port, new AsyncCallback(AddressOf ConnectionDone), client)

The failure to resolve delegate expressions is a known issue, and there are other bug reports open about it (in bugzilla.novell.com), so I'm closing this bug.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2011-09-02 19:09:55 UTC
I've opened another bug report about the internal exception for the invalid code:

http://bugzilla.xamarin.com/show_bug.cgi?id=611