You are not required to be a Canadian (citizen or permanent resident) to get married in Canada. You can come to Canada on a visitor’s visa and marry your BF.
Marrying a Canadian does not automatically give you status in Canada though. You must apply for status, which you can do through Family Sponsorship, if you’re married to a Canadian.
You mentioned in a comment on another answer that you are gay. That is not relevant. Same sex marriage is legal in Canada and same sex couples can apply for a spouse PR through the Family Sponsorship program.